BeforeSyncTCollectionService<T extends TWriteableId, API extends TFirestoreApi<T>> class abstract

A collection service that allows notification before synchronizing data.

Extends TCollectionService to provide a hook for notifying before the local state is updated with new data from Firestore.

Type Parameters:

  • T - The document type, must extend TWriteableId
  • API - The Firestore API type, must extend TFirestoreApi
Inheritance

Constructors

BeforeSyncTCollectionService({required API api})
Creates a new BeforeSyncTCollectionService instance.

Properties

analytics → TAnalytics
Provides the configured TAnalytics functionality through the Turbolytics mixin per type of D.
latefinalinherited
api → API
The Firestore API instance used for remote operations.
finalinherited
cachedUserId String?
The ID of the currently authenticated user.
getter/setter pairinherited
docsPerId ValueListenable<Map<String, T>>
Value listenable for the document collection state.
no setterinherited
docsPerIdNotifier → TNotifier<Map<String, T>>
Local state for documents, indexed by their IDs.
finalinherited
hasDocs bool
Whether the collection has any documents.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
isReady Future<void>
Future that completes when the service is ready to use.
no setterinherited
listenable Listenable
Listenable for the document collection state.
no setterinherited
location String
Used to define the location of Turbolytics logging and implementation.
no setterinherited
log → TLog
Used to provide all logging capabilities.
latefinalinherited
onAuth FutureOr<void> Function(User user)?
Called when a user is authenticated.
getter/setter pairinherited
onData Future<void> Function(List<T>? value, User? user)
Handles incoming data updates from Firestore with pre-sync notification.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stream FutureOr<Stream<List<T>?>> Function(User user)
Returns a stream of data for the authenticated user.
no setterinherited

Methods

analyticsAs<A extends TAnalytics>() → A
Provides the configured TAnalytics functionality through the Turbolytics mixin per type of A.
inherited
beforeSyncNotifyUpdate(List<T> docs) Future<void>
Called before the local state is updated with new data.
createDoc({Transaction? transaction, required CreateDocDef<T> doc, bool doNotifyListeners = true}) Future<TurboResponse<T>>
Creates a new document both locally and in Firestore.
inherited
createDocs({Transaction? transaction, required List<CreateDocDef<T>> docs, bool doNotifyListeners = true}) Future<TurboResponse<List<T>>>
Creates multiple documents both locally and in Firestore.
inherited
createLocalDoc({required CreateDocDef<T> doc, bool doNotifyListeners = true}) → T
Creates a new document in local state.
inherited
createLocalDocs({required List<CreateDocDef<T>> docs, bool doNotifyListeners = true}) List<T>
Creates multiple new documents in local state.
inherited
deleteDoc({required String id, bool doNotifyListeners = true, Transaction? transaction}) Future<TurboResponse<void>>
Deletes a document both locally and from Firestore.
inherited
deleteDocs({Transaction? transaction, required List<String> ids, bool doNotifyListeners = true}) Future<TurboResponse<void>>
Deletes multiple documents both locally and from Firestore.
inherited
deleteLocalDoc({required String id, bool doNotifyListeners = true}) → void
Deletes a document from local state.
inherited
deleteLocalDocs({required List<String> ids, bool doNotifyListeners = true}) → void
Deletes multiple documents from local state.
inherited
dispose() Future<void>
Disposes of the service by cleaning up resources.
inherited
exists(String id) bool
Whether a document with the given ID exists.
inherited
findById(String id) → T
Finds a document by its ID. Throws if not found.
inherited
getCustomClaim<T>(String key, {T? defaultValue}) → T?
Returns a specific custom claim by key.
inherited
getCustomClaims() Map<String, dynamic>?
Returns all custom claims from the cached token.
inherited
getTokenResult() Future<IdTokenResult?>
Returns the cached token result with claims.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onDone(int nrOfRetry, int maxNrOfRetry) → void
Called when the stream is done.
inherited
onError(TFirestoreException error) → void
Called when a stream error occurs.
inherited
rebuild() → void
Forces a rebuild of the local state.
inherited
resetAndTryInitialiseStream() Future<void>
Resets and reinitialized the stream.
inherited
toString() String
A string representation of this object.
inherited
tryFindById(String? id) → T?
Finds a document by its ID. Returns null if not found.
inherited
tryHandleFirebaseAuthException<T>({required FirebaseAuthException firebaseAuthException, required TLog log}) → TurboResponse<T>
Handles Firebase Authentication exceptions and converts them to TurboResponse.
inherited
tryInitialiseStream() Future<void>
Initializes the authentication state stream and data synchronization.
inherited
turboVars<V extends TAuthVars>({String? id}) → V
Returns a new instance of V with basic variables filled in.
inherited
updateDoc({Transaction? transaction, required String id, required UpdateDocDef<T> doc, TWriteableId remoteUpdateRequestBuilder(T doc)?, bool doNotifyListeners = true}) Future<TurboResponse<T>>
Updates a document both locally and in Firestore.
inherited
updateDocs({Transaction? transaction, required List<String> ids, required UpdateDocDef<T> doc, bool doNotifyListeners = true}) Future<TurboResponse<List<T>>>
Updates multiple documents both locally and in Firestore.
inherited
updateLocalDoc({required String id, required UpdateDocDef<T> doc, bool doNotifyListeners = true}) → T
Updates an existing document in local state.
inherited
updateLocalDocs({required List<String> ids, required UpdateDocDef<T> doc, bool doNotifyListeners = true}) List<T>
Updates multiple existing documents in local state.
inherited
upsertDoc({Transaction? transaction, required String id, required UpsertDocDef<T> doc, TSerializable remoteUpdateRequestBuilder(T doc)?, bool doNotifyListeners = true}) Future<TurboResponse<T>>
Upserts (updates or inserts) a document both locally and in Firestore.
inherited
upsertDocs({Transaction? transaction, required List<String> ids, required UpsertDocDef<T> doc, bool doNotifyListeners = true}) Future<TurboResponse<List<T>>>
Upserts (updates or inserts) multiple documents both locally and in Firestore.
inherited
upsertLocalDoc({required String id, required UpsertDocDef<T> doc, bool doNotifyListeners = true}) → T
Upserts (updates or inserts) a document in local state.
inherited
upsertLocalDocs({required List<String> ids, required UpsertDocDef<T> doc, bool doNotifyListeners = true}) List<T>
Upserts (updates or inserts) multiple documents in local state.
inherited

Operators

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