Ditto 4.8.0-rc.2
Loading...
Searching...
No Matches
LiveQuery.hpp
1#ifndef _DITTO_LIVE_QUERY_
2#define _DITTO_LIVE_QUERY_
3
4#include "Document.hpp"
5#include "Helpers.hpp"
6#include "LiveQueryEvent.hpp"
7#include "LiveQueryMove.hpp"
8#include "Observer.hpp"
9#include "SingleDocumentLiveQueryEvent.hpp"
10#include "Subscription.hpp"
11#include "json.hpp"
12
13#include <functional>
14#include <memory>
15#include <string>
16#include <vector>
17
18namespace ditto {
19class DittoHandleWrapper;
20class OrderBy;
21
26typedef std::function<void(std::shared_ptr<Document>,
27 SingleDocumentLiveQueryEvent)>
28 SingleDocumentLiveQueryEventCallback;
29
35 std::function<void(std::shared_ptr<Document>, SingleDocumentLiveQueryEvent)>
36 fn;
37};
38
44typedef std::function<void(std::shared_ptr<Document>,
46 std::function<void()> &)>
47 SingleDocumentLiveQueryEventWithNextSignalCallback;
48
55 std::function<void(std::shared_ptr<Document>, SingleDocumentLiveQueryEvent,
56 std::function<void()> &)>
57 fn;
58};
59
64typedef std::function<void(std::vector<Document>, LiveQueryEvent)>
65 LiveQueryEventCallback;
66
72 std::function<void(std::vector<Document>, LiveQueryEvent)> fn;
73};
74
80typedef std::function<void(std::vector<Document>, LiveQueryEvent,
81 std::function<void()> &)>
82 LiveQueryEventWithNextSignalCallback;
83
90 std::function<void(std::vector<Document>, LiveQueryEvent,
91 std::function<void()> &)>
92 fn;
93};
94
103class LiveQuery : public Observer {
104public:
105 ~LiveQuery(); // required by pimpl.
107 LiveQuery &operator=(LiveQuery &&);
108
109 struct ArcCtx;
110
111private:
112 LiveQuery(std::shared_ptr<DittoHandleWrapper> const &ditto_handle_wrapper,
113 std::string query, nlohmann::json query_args, std::string coll_name,
114 std::shared_ptr<OrderBy> const &order_by, int32_t limit,
115 uint32_t offset, LiveQueryAvailability_t availability,
116 std::unique_ptr<Subscription> &&subscription,
117 LiveQueryEventWithNextSignalCallback &&event_callback);
118
119 void on_stop() override;
120 // Non-trivial dtor requires manual swap for assignment operators.
121 static void swap(LiveQuery &lhs, LiveQuery &rhs) noexcept;
122
123 std::unique_ptr<ArcCtx> ctx; // pimpl.
124
125 friend class PendingCursorOperation;
126 friend class PendingIDSpecificOperation;
127};
128
129} // namespace ditto
130
131#endif
The events that you receive when dealing with live queries.
Definition LiveQueryEvent.hpp:15
The type that is returned when calling observe_local. It handles the logic for calling the event hand...
Definition LiveQuery.hpp:103
An observation token returned by any observation API in the Ditto SDK. Retain this object to continue...
Definition Observer.hpp:11
These objects are returned when using find-like functionality on Collection objects.
Definition PendingCursorOperation.hpp:44
These objects are returned when using Collection::find_by_id functionality.
Definition PendingIDSpecificOperation.hpp:40
Provides information about a live query event relating to a single document live query.
Definition SingleDocumentLiveQueryEvent.hpp:16
Definition LiveQuery.cpp:47
A thin wrapper around a function that will get called when there are updates relating to a live query...
Definition LiveQuery.hpp:71
A thin wrapper around a function that will get called when there are updates relating to a live query...
Definition LiveQuery.hpp:89
A thin wrapper around a function that will get called when there are updates relating to a live query...
Definition LiveQuery.hpp:34
A thin wrapper around a function that will get called when there are updates relating to a live query...
Definition LiveQuery.hpp:54