THookDocService<DTO extends TWriteableId, MODEL extends TModel<DTO> > class
abstract
A document service that allows notification both before and after synchronizing data.
Extends TDocService to provide hooks for notifying both before and after the local state is updated with new data from Firestore.
Type Parameters:
DTO- The document type, must extendTWriteableId
- Inheritance
-
- Object
- TAuthSyncService<
DTO> - TDocService<
DTO, MODEL> - THookDocService
Constructors
-
THookDocService({required TFirestoreCollection<
DTO> collection, required TDocValueBuilderDef<DTO, MODEL> defaultValue, required TDocModelBuilderDef<DTO, MODEL> modelBuilder, TDocValueBuilderDef<DTO, MODEL> ? onMissingRemoteValue, TDocApiBuilderDef<DTO, MODEL> ? apiBuilder, TDocValueBuilderDef<DTO, MODEL> ? initialValue, bool initialiseStream = true, TDocStreamBuilderDef<DTO, MODEL> ? streamBuilder, ValueChanged<DTO?> ? afterLocalNotifyUpdate, ValueChanged<DTO?> ? beforeLocalNotifyUpdate, IFirestoreCacheService? firestoreCacheService, List<Future> readyDeps(User user)?}) - Creates a new THookDocService instance.
Properties
-
afterLocalNotifyUpdate
↔ ValueChanged<
DTO?> ? -
Called after local state is updated.
getter/setter pairinherited
- analytics → TAnalytics
-
Provides the configured
TAnalyticsfunctionality through theTurbolyticsmixin per type ofD.latefinalinherited -
api
→ TFirestoreApi<
DTO> -
The Firestore API instance for remote operations.
latefinalinherited
-
apiBuilder
→ TDocApiBuilderDef<
DTO, MODEL> ? -
Optional builder function to create the Firestore API instance. If not provided, the API will be created using the collection's
api()method.finalinherited -
beforeLocalNotifyUpdate
↔ ValueChanged<
DTO?> ? -
Called before local state is updated.
getter/setter pairinherited
-
collection
→ TFirestoreCollection<
DTO> -
The Firestore collection definition that this service manages.
finalinherited
-
defaultValue
→ TDocValueBuilderDef<
DTO, MODEL> -
Function to provide default document value.
finalinherited
-
doc
→ ValueListenable<
MODEL> -
Value listenable for the document state.
no setterinherited
- firestoreCacheService → IFirestoreCacheService?
-
Optional Firestore cache service for caching document data locally.
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → String
-
Whether a document exists in local state.
The document ID.
no setterinherited
-
initialValue
→ TDocValueBuilderDef<
DTO, MODEL> ? -
Function to provide initial document value.
finalinherited
-
isReady
→ Future<
void> -
Future that completes when the service is ready.
no setterinherited
- listenable → Listenable
-
Listenable for the document 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
-
modelBuilder
→ TDocModelBuilderDef<
DTO, MODEL> -
Function to convert between DTO and MODEL for local state management.
finalinherited
- onAuth ↔ FutureOr Function(User user)?
-
Called when a user is authenticated.
getter/setter pairinherited
-
onData
→ Future<
void> Function(DTO? value, User? user) -
Handles incoming data updates from Firestore with pre and post-sync notifications.
no setteroverride
-
onMissingRemoteValue
→ TDocValueBuilderDef<
DTO, MODEL> ? -
Whether to attempt to create a missing remote document if the local state is default and no remote document exists.
finalinherited
-
readyDeps
→ List<
Future> Function(User user)? -
List of dependencies to wait for before anything else.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
stream
→ Stream<
DTO?> Function(User user) -
Returns a stream of data for the authenticated user.
no setterinherited
-
streamBuilder
→ TDocStreamBuilderDef<
DTO, MODEL> ? -
Optional builder function to create the Firestore stream. If not provided, the stream will be created using the API's
streamAllWithConverter()method.finalinherited - user ↔ User?
-
The currently authenticated Firebase user.
getter/setter pairinherited
- userId → String?
-
The ID of the currently authenticated user.
no setterinherited
Methods
-
afterSyncNotifyUpdate(
DTO? doc) → Future< void> - Called after the local state has been updated with new data.
-
analyticsAs<
A extends TAnalytics> () → A -
Provides the configured
TAnalyticsfunctionality through theTurbolyticsmixin per type ofA.inherited -
beforeSyncNotifyUpdate(
DTO? doc) → Future< void> - Called before the local state is updated with new data.
-
clearLocalDoc(
{bool doNotifyListeners = true}) → void -
Clears the local document state.
inherited
-
createDoc(
{Transaction? transaction, String? id, required CreateDocDef< DTO, MODEL> doc, bool doNotifyListeners = true}) → Future<TurboResponse< DTO> > -
Creates a new document both locally and in Firestore.
inherited
-
createLocalDoc(
{String? id, required CreateDocDef< DTO, MODEL> doc, bool doNotifyListeners = true}) → DTO -
Creates a new document in local state.
inherited
-
defaultDoc(
) → MODEL -
inherited
-
defaultDto(
) → DTO -
inherited
-
deleteDoc(
{required String id, bool doNotifyListeners = true, Transaction? transaction}) → Future< TurboResponse< void> > -
Deletes a document both locally and from Firestore.
inherited
-
deleteLocalDoc(
{required String id, bool doNotifyListeners = true}) → void -
Deletes a document from local state.
inherited
-
dispose(
) → Future< void> -
Disposes of the document service and releases resources.
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
-
handleMissingRemoteValue(
) → Future< void> -
inherited
-
initialDoc(
) → MODEL -
inherited
-
initialDto(
) → DTO -
inherited
-
markAsReady(
) → void -
Marks the service as ready by completing the ready state.
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
-
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
-
updateDoc(
{Transaction? transaction, required String id, required UpdateDocDef< DTO, MODEL> doc, TWriteable remoteUpdateRequestBuilder(DTO doc)?, bool doNotifyListeners = true}) → Future<TurboResponse< DTO> > -
Updates a document both locally and in Firestore.
inherited
-
updateLocalDoc(
{required String id, required UpdateDocDef< DTO, MODEL> doc, bool doNotifyListeners = true}) → DTO -
Updates an existing document in local state.
inherited
-
upsertDoc(
{Transaction? transaction, required String id, required UpsertDocDef< DTO, MODEL> doc, TWriteableId remoteUpdateRequestBuilder(DTO doc)?, bool doNotifyListeners = true}) → Future<TurboResponse< DTO> > -
Upserts (updates or inserts) a document both locally and in Firestore.
inherited
-
upsertLocalDoc(
{required String id, required UpsertDocDef< DTO, MODEL> doc, bool doNotifyListeners = true}) → DTO -
Upserts (updates or inserts) a document in local state.
inherited
-
vars<
V extends TVars> ({String? id}) → V -
Returns a new instance of
Vwith basic variables filled in.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited