Add immediate_notify and is_new to entry listener.

On the callback function, is_new indicates the value is newly added.

On adding a callback function, immediate_notify indicates the callback
should be called once (with is_new=true) for each matching entry that
already exists.
This commit is contained in:
Peter Johnson
2015-07-23 01:02:53 -07:00
parent 79f732f239
commit 6f940bcaaf
4 changed files with 16 additions and 10 deletions

View File

@@ -166,13 +166,15 @@ void Flush();
*/
typedef std::function<void(unsigned int uid, StringRef name,
std::shared_ptr<Value> value)> EntryListenerCallback;
std::shared_ptr<Value> value, bool is_new)>
EntryListenerCallback;
typedef std::function<void(unsigned int uid, int connected,
const ConnectionInfo& conn)>
ConnectionListenerCallback;
unsigned int AddEntryListener(StringRef prefix, EntryListenerCallback callback);
unsigned int AddEntryListener(StringRef prefix, EntryListenerCallback callback,
bool immediate_notify);
void RemoveEntryListener(unsigned int entry_listener_uid);
unsigned int AddConnectionListener(ConnectionListenerCallback callback);
void RemoveConnectionListener(unsigned int conn_listener_uid);