Ditto 2.0.6
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;
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
109 friend class PendingCursorOperation;
110 friend class PendingIDSpecificOperation;
111
112public:
119 void stop();
120
121 ~LiveQuery();
122
123private:
124 LiveQuery(std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper,
125 std::string query, nlohmann::json query_args, std::string coll_name,
126 std::shared_ptr<OrderBy> &order_by, int32_t limit, uint32_t offset,
127 LiveQueryAvailability_t availability, Subscription *subscription,
128 LiveQueryEventWithNextSignalCallback event_callback);
129
130 class LiveQueryCtx;
131 LiveQueryCtx *ctx;
132 bool stopped;
133};
134
135} // namespace ditto
136
137#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:108
void stop()
Stop the live query from delivering updates.
Definition: LiveQuery.cpp:202
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:18
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