Ditto 4.13.1
 
Loading...
Searching...
No Matches
StoreObserver.hpp
1#ifndef DITTO_STORE_OBSERVER_H
2#define DITTO_STORE_OBSERVER_H
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
25using StoreObservationHandler = std::function<void(QueryResult)>;
26using NextSignal = std::function<void()>;
27
34 std::function<void(QueryResult, NextSignal)>;
35
42class StoreObserver : Observer,
43 public std::enable_shared_from_this<StoreObserver> {
44public:
45 ~StoreObserver(); // required by pimpl.
46 StoreObserver(StoreObserver &&);
47 StoreObserver &operator=(StoreObserver &&);
48
49 struct ArcCtx;
50
57 void cancel();
58
65
66private:
67 void on_stop() override;
68 StoreObserver(std::weak_ptr<Ditto::Fields> weak_ditto_fields,
69 std::string query, nlohmann::json query_args,
70 LiveQueryAvailability_t,
72 int64_t id();
73
74 std::unique_ptr<ArcCtx> ctx; // pimpl.
75
76 friend class Store;
77};
78
79} // namespace ditto
80
81#endif
Observer()
Constructs a new Observer.
Represents the returned results when executing a DQL query, containing a QueryResultItem for each mat...
Definition QueryResult.hpp:121
Provides access to Collections and a transaction API.
Definition Store.hpp:65
void cancel()
Cancels the observation. The handler that was passed in when registering this store observer will no ...
bool is_cancelled()
Convenience property, returns true if the store observer has been cancelled, otherwise returns false....
Namespace for the Ditto C++ SDK types and functions.
Definition AbstractDocumentPath.hpp:19
std::function< void(QueryResult)> StoreObservationHandler
A function that will get called when there are updates relating to a store observer.
Definition StoreObserver.hpp:25
std::function< void(QueryResult, NextSignal)> StoreObservationHandlerWithNextSignal
A function that will get called when there are updates relating to a store observer,...
Definition StoreObserver.hpp:33