TPostCollectionService<DTO extends TWriteableId, MODEL extends TModel<DTO>> class abstract

A collection service that allows notification after synchronizing data.

Extends TCollectionService to provide a hook for notifying after the local state has been updated with new data from Firestore.

Type Parameters:

  • DTO - The document type, must extend TWriteableId
Inheritance

Constructors

TPostCollectionService({required TFirestoreCollection<DTO> collection, required TCollectionModelBuilderDef<DTO, MODEL> modelBuilder, TCollectionApiBuilderDef<DTO, MODEL>? apiBuilder, bool initialiseStream = true, TCollectionValueBuilderDef<DTO, MODEL>? defaultValue, IFirestoreCacheService? firestoreCacheService, TCollectionValueBuilderDef<DTO, MODEL>? initialValue, TModelDocsBuilderDef<DTO, MODEL>? modelDocsBuilder, TCollectionStreamBuilderDef<DTO, MODEL>? streamBuilder})
Creates a new TPostCollectionService instance.

Properties

analytics → TAnalytics
Provides the configured TAnalytics functionality through the Turbolytics mixin per type of D.
latefinalinherited
api TFirestoreApi<DTO>
The Firestore API instance for remote operations.
latefinalinherited
apiBuilder TCollectionApiBuilderDef<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
collection TFirestoreCollection<DTO>
The Firestore collection definition that this service manages.
finalinherited
defaultValue TCollectionValueBuilderDef<DTO, MODEL>?
Function to provide default document value.
finalinherited
docs ValueListenable<TModelDocs<DTO, MODEL>>
A listenable that provides the current documents indexed by their IDs.
no setterinherited
docsNotifier → TNotifier<TModelDocs<DTO, MODEL>>
Local state for documents, indexed by their IDs.
latefinalinherited
docsPerId ValueListenable<TModelDocs<DTO, MODEL>>
no setterinherited
firestoreCacheService IFirestoreCacheService?
Optional Firestore cache service for caching document data locally.
finalinherited
hasDocs bool
Whether the collection has any documents.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
initialSortFilteredListsMap TSortFilteredListsMap<DTO, MODEL> Function()?
Optional map of sorting and filtering definitions for managing sorted and filtered lists of documents. This can be used to maintain multiple views of the data based on different criteria.
finalinherited
initialValue TCollectionValueBuilderDef<DTO, MODEL>?
Function to provide initial document value.
finalinherited
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
modelBuilder TCollectionModelBuilderDef<DTO, MODEL>
Function to convert Firestore documents into local model instances.
finalinherited
modelDocsBuilder TModelDocsBuilderDef<DTO, MODEL>?
Optional builder function to create the local model documents state from a list of DTOs. If not provided, the state will be created using TModelDocs.fromDtos().
finalinherited
onAuth FutureOr<void> Function(User user)?
Called when a user is authenticated.
getter/setter pairinherited
onData Future<void> Function(List<DTO>? value, User? user)
Handles incoming data updates from Firestore with post-sync notification.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stream Stream<List<DTO>> Function(User user)
Returns a stream of data for the authenticated user.
no setterinherited
streamBuilder TCollectionStreamBuilderDef<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

addList(Object id, TSortFilteredList<DTO, MODEL> list) → void
Adds a sorted and filtered list of documents to the local state.
inherited
afterSyncNotifyUpdate(List<DTO> docs) Future<void>
Called after the local state has been updated with new data.
analyticsAs<A extends TAnalytics>() → A
Provides the configured TAnalytics functionality through the Turbolytics mixin per type of A.
inherited
clearLocalDocs({bool doNotifyListeners = true}) → void
Clears all documents from local state.
inherited
createDoc({Transaction? transaction, required CreateDocDef<DTO, MODEL> doc, bool doNotifyListeners = true}) Future<TurboResponse<DTO>>
Creates a new document both locally and in Firestore.
inherited
createDocs({Transaction? transaction, required List<CreateDocDef<DTO, MODEL>> docs, bool doNotifyListeners = true}) Future<TurboResponse<List<DTO>>>
Creates multiple documents both locally and in Firestore.
inherited
createLocalDoc({required CreateDocDef<DTO, MODEL> doc, bool doNotifyListeners = true}) → DTO
Creates a new document in local state.
inherited
createLocalDocs({required List<CreateDocDef<DTO, MODEL>> docs, bool doNotifyListeners = true}) List<DTO>
Creates multiple new documents in local state.
inherited
defaultDocs() TModelDocs<DTO, MODEL>
inherited
defaultValues() List<DTO>
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) → MODEL
Finds a document by its ID. Throws if not found.
inherited
getById({required String id, String? collectionPathOverride, bool tryCache = true, bool forceCacheRefresh = false}) Future<TurboResponse<MODEL>>
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
getList(Object id) List<MODEL>
Returns a list of documents for the given list ID. Throws if the list does not exist.
inherited
getTokenResult() Future<IdTokenResult?>
Returns the cached token result with claims.
inherited
initialDocs() TModelDocs<DTO, MODEL>
inherited
initialValues() List<DTO>?
inherited
listAll({bool tryCache = true, bool forceCacheRefresh = false}) Future<TurboResponse<List<MODEL>>>
inherited
listByIds(Iterable<String> ids) List<MODEL>
inherited
listByQuery({required CollectionReferenceDef<DTO> collectionReferenceQuery, required String whereDescription, bool tryCache = true, bool forceCacheRefresh = false}) Future<TurboResponse<List<MODEL>>>
inherited
listBySearchTermWithConverter({required String searchTerm, required String searchField, required TSearchTermType searchTermType, bool doSearchNumberEquivalent = false, int? limit}) Future<TurboResponse<List<MODEL>>>
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
removeList(Object id) → void
Removes a sorted and filtered list of documents from the local state.
inherited
resetAndTryInitialiseStream() Future<void>
Resets and reinitialized the stream.
inherited
resetLocalDocs({bool doNotifyListeners = true}) → void
Resets the local documents to their initial value.
inherited
toString() String
A string representation of this object.
inherited
tryFindById(String? id) → MODEL?
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
updateDoc({Transaction? transaction, required String id, required UpdateDocDef<DTO, MODEL> doc, TWriteableId remoteUpdateRequestBuilder(DTO doc)?, bool doNotifyListeners = true}) Future<TurboResponse<DTO>>
Updates a document both locally and in Firestore.
inherited
updateDocs({Transaction? transaction, required List<String> ids, required UpdateDocDef<DTO, MODEL> doc, bool doNotifyListeners = true}) Future<TurboResponse<List<DTO>>>
Updates multiple documents 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
updateLocalDocs({required List<String> ids, required UpdateDocDef<DTO, MODEL> doc, bool doNotifyListeners = true}) List<DTO>
Updates multiple existing documents in local state.
inherited
upsertDoc({Transaction? transaction, required String id, required UpsertDocDef<DTO, MODEL> doc, TSerializable remoteUpdateRequestBuilder(DTO doc)?, bool doNotifyListeners = true}) Future<TurboResponse<DTO>>
Upserts (updates or inserts) a document both locally and in Firestore.
inherited
upsertDocs({Transaction? transaction, required List<String> ids, required UpsertDocDef<DTO, MODEL> doc, bool doNotifyListeners = true}) Future<TurboResponse<List<DTO>>>
Upserts (updates or inserts) multiple documents 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
upsertLocalDocs({required List<String> ids, required UpsertDocDef<DTO, MODEL> doc, bool doNotifyListeners = true}) List<DTO>
Upserts (updates or inserts) multiple documents in local state.
inherited
upsertResult({required DTO dto, bool doNotifyListeners = true}) → MODEL
inherited
upsertResults({required Iterable<DTO> dtos, bool doNotifyListeners = true}) List<MODEL>
inherited
vars<V extends TVars>({String? id}) → V
Returns a new instance of V with basic variables filled in.
inherited

Operators

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