Ditto 4.6.0
Loading...
Searching...
No Matches
StoreObserver.hpp
1#ifndef _DITTO_STORE_OBSERVER_
2#define _DITTO_STORE_OBSERVER_
3
4#include "Ditto.hpp"
5#include "Document.hpp"
6#include "Helpers.hpp"
7#include "Observer.hpp"
8#include "json.hpp"
9
10#include <functional>
11#include <memory>
12#include <string>
13#include <vector>
14
15#include "dittoffi.hpp"
16
17namespace ditto {
18class Store;
19class QueryResult;
20
25typedef std::function<void(QueryResult)> StoreObservationHandler;
26
27typedef std::function<void()> NextSignal;
28
34typedef std::function<void(QueryResult, NextSignal)>
35 StoreObservationHandlerWithNextSignal;
36
44 public std::enable_shared_from_this<StoreObserver> {
45public:
46 ~StoreObserver(); // required by pimpl.
48 StoreObserver &operator=(StoreObserver &&);
49
50 struct ArcCtx;
51
58 void cancel();
59
65 bool is_cancelled();
66
67private:
68 void on_stop() override;
69 StoreObserver(std::weak_ptr<Ditto::Fields> weak_ditto_fields,
70 std::string query, nlohmann::json query_args,
72 StoreObservationHandlerWithNextSignal event_callback);
73 int64_t id();
74
75 std::unique_ptr<ArcCtx> ctx; // pimpl.
76
77 friend class Store;
78};
79
80} // namespace ditto
81
82#endif
An observation token returned by any observation API in the Ditto SDK. Retain this object to continue...
Definition Observer.hpp:11
Provides access to Collections and a write transaction API.
Definition Store.hpp:29
Definition StoreObserver.hpp:44
void cancel()
Cancels the observation. The handler that was passed in when registering this store observer will no ...
Definition StoreObserver.cpp:149
bool is_cancelled()
Convenience property, returns true if the store observer has been cancelled, otherwise returns false....
Definition StoreObserver.cpp:151
basic_json<> json
default JSON class
Definition json.hpp:2933
Definition Arc.hpp:10