CollectionWatcher class

Collection watcher for real-time document updates

Watches a collection for create, update, and delete events with automatic reconnection.

Example:

final watcher = CollectionWatcher('books', apiKey);

watcher.onCreate((data) {
  print('New document: ${data['data']}');
});

watcher.onUpdate((data) {
  print('Updated document: ${data['data']}');
});

watcher.onDelete((data) {
  print('Deleted document: ${data['data']}');
});

watcher.connect();

// Later, when done
watcher.disconnect();

Constructors

CollectionWatcher(String collectionName, String apiKey, {Map<String, dynamic>? filters, String baseURL = 'https://api.cocobase.buzz'})

Properties

apiKey String
final
filters Map<String, dynamic>?
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
url String
final

Methods

connect() → void
Connect to the collection WebSocket
disconnect() → void
Disconnect from the WebSocket
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onClose(Listener callback) → void
Called when connection is closed
onConnected(Listener callback) → void
Called when connection is established
onCreate(Listener callback) → void
Called when a document is created
onDelete(Listener callback) → void
Called when a document is deleted
onError(Listener callback) → void
Called when an error occurs
onUpdate(Listener callback) → void
Called when a document is updated
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited