Ditto 1.1.7
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 "SingleDocumentLiveQueryEvent.hpp"
9#include "Subscription.hpp"
10
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;
25
30typedef std::function<void(std::shared_ptr<Document>,
31 SingleDocumentLiveQueryEvent)>
32 SingleDocumentLiveQueryEventCallback;
33
39 std::function<void(std::shared_ptr<Document>, SingleDocumentLiveQueryEvent)>
40 fn;
41};
42
48typedef std::function<void(std::shared_ptr<Document>,
50 std::function<void()> &)>
51 SingleDocumentLiveQueryEventWithNextSignalCallback;
52
59 std::function<void(std::shared_ptr<Document>, SingleDocumentLiveQueryEvent,
60 std::function<void()> &)>
61 fn;
62};
63
68typedef std::function<void(std::vector<Document>, LiveQueryEvent)>
69 LiveQueryEventCallback;
70
76 std::function<void(std::vector<Document>, LiveQueryEvent)> fn;
77};
78
84typedef std::function<void(std::vector<Document>, LiveQueryEvent,
85 std::function<void()> &)>
86 LiveQueryEventWithNextSignalCallback;
87
94 std::function<void(std::vector<Document>, LiveQueryEvent,
95 std::function<void()> &)>
96 fn;
97};
98
108 friend class PendingCursorOperation;
109 friend class PendingIDSpecificOperation;
110
111public:
118 void stop();
119
120 ~LiveQuery();
121
122private:
123 LiveQuery(std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper,
124 std::string query, nlohmann::json query_args, std::string coll_name,
125 std::vector<COrderByParam_t> &order_by, int32_t limit,
126 uint32_t offset, LiveQueryAvailability_t availability,
127 Subscription *subscription,
128 LiveQueryEventWithNextSignalCallback event_callback);
129 LiveQuery(std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper,
130 std::string query, nlohmann::json query_args, std::string coll_name,
131 std::vector<COrderByParam_t> &order_by, int32_t limit,
132 uint32_t offset, LiveQueryAvailability_t availability,
133 Subscription *subscription,
134 LiveQueryWithNextSignalEventHandler event_handler) DITTO_DEPRECATED;
135
136 class LiveQueryCtx;
137 LiveQueryCtx *ctx;
138 bool stopped;
139};
140
141} // namespace ditto
142
143#endif
The events that you receive when dealing with live queries.
Definition: LiveQueryEvent.hpp:15
The type that is returned when calling Collection::observe. It handles the logic for calling the even...
Definition: LiveQuery.hpp:107
void stop()
Stop the live query from delivering updates.
Definition: LiveQuery.cpp:212
These objects are returned when using find-like functionality on Collection objects.
Definition: PendingCursorOperation.hpp:49
These objects are returned when using Collection::find_by_id functionality.
Definition: PendingIDSpecificOperation.hpp:44
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:17
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:75
A thin wrapper around a function that will get called when there are updates relating to a live query...
Definition: LiveQuery.hpp:93
A thin wrapper around a function that will get called when there are updates relating to a live query...
Definition: LiveQuery.hpp:38
A thin wrapper around a function that will get called when there are updates relating to a live query...
Definition: LiveQuery.hpp:58