Ditto 4.3.0
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
18#ifdef __OBJC__
19#warning FIXME: remove include
20#endif
21#include "dittoffi.hpp"
22
23namespace ditto {
24class DittoHandleWrapper;
25class OrderBy;
26
31typedef std::function<void(std::shared_ptr<Document>,
32 SingleDocumentLiveQueryEvent)>
33 SingleDocumentLiveQueryEventCallback;
34
40 std::function<void(std::shared_ptr<Document>, SingleDocumentLiveQueryEvent)>
41 fn;
42};
43
49typedef std::function<void(std::shared_ptr<Document>,
51 std::function<void()> &)>
52 SingleDocumentLiveQueryEventWithNextSignalCallback;
53
60 std::function<void(std::shared_ptr<Document>, SingleDocumentLiveQueryEvent,
61 std::function<void()> &)>
62 fn;
63};
64
69typedef std::function<void(std::vector<Document>, LiveQueryEvent)>
70 LiveQueryEventCallback;
71
77 std::function<void(std::vector<Document>, LiveQueryEvent)> fn;
78};
79
85typedef std::function<void(std::vector<Document>, LiveQueryEvent,
86 std::function<void()> &)>
87 LiveQueryEventWithNextSignalCallback;
88
95 std::function<void(std::vector<Document>, LiveQueryEvent,
96 std::function<void()> &)>
97 fn;
98};
99
108class LiveQuery : public Observer {
109 friend class PendingCursorOperation;
110 friend class PendingIDSpecificOperation;
111
112public:
113 ~LiveQuery();
114
115private:
116 void on_stop() override;
117 LiveQuery(std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper,
118 std::string query, nlohmann::json query_args, std::string coll_name,
119 std::shared_ptr<OrderBy> &order_by, int32_t limit, uint32_t offset,
120 LiveQueryAvailability_t availability, Subscription *subscription,
121 LiveQueryEventWithNextSignalCallback event_callback);
122
123 class LiveQueryCtx;
124 LiveQueryCtx *ctx;
125 bool stopped;
126};
127
128} // namespace ditto
129
130#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:108
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
While Subscription objects remain in scope they ensure that documents in the collection specified,...
Definition Subscription.hpp:19
basic_json<> json
default JSON class
Definition json.hpp:2933
A thin wrapper around a function that will get called when there are updates relating to a live query...
Definition LiveQuery.hpp:76
A thin wrapper around a function that will get called when there are updates relating to a live query...
Definition LiveQuery.hpp:94
A thin wrapper around a function that will get called when there are updates relating to a live query...
Definition LiveQuery.hpp:39
A thin wrapper around a function that will get called when there are updates relating to a live query...
Definition LiveQuery.hpp:59