synckit 0.3.2
synckit: ^0.3.2 copied to clipboard
A Package to Sync data b/w Network and Local Storage.
0.3.2 #
New Features #
Batch Operations Support
Added support for batch operations to perform multiple updates/deletes in a single Firestore write batch, improving performance and ensuring atomicity.
-
[SyncBatch]: New class wrapping Firestore
WriteBatchwith aCompleter<void>for async completion tracking.batch: The underlying FirestoreWriteBatch.completer: ACompleter<void>that completes when the batch is committed.commit(): Commits the batch and completes the completer.
-
[SyncManager]: Added batch operation methods:
batchUpdate(Dataset<T> data, SyncBatch syncBatch): Performs a batch update operation using the providedSyncBatch. Updates network first, waits for batch commit, then updates local storage.batchRemove(Dataset<T> data, SyncBatch syncBatch): Performs a batch remove operation using the providedSyncBatch. Deletes from network first, waits for batch commit, then deletes from local storage.
-
[SyncedState]: Added batch operation methods:
batchUpdate(T value, SyncBatch batch): Queues a value update in the batch and updates local state immediately. Note: Callbatch.commit()after all batch operations.batchRemoveAll(Iterable<String> ids, SyncBatch batch): Queues removal of multiple items by IDs in the batch and updates local state immediately.
0.3.1 #
Fixed bug of syncLocalWithNetworkOnFetch not working.
0.3.0 #
Breaking Changes #
- [NetworkStorage]: Renamed
defaultDocPathparameter topathfor better clarity and consistency.
New Features #
Collection-Based Storage Mode
Added support for collection-based storage in NetworkStorage, where each record is stored as a separate Firestore document instead of all records in a single document. This is useful for larger datasets or when you need to query individual records.
- New
collectionBasedparameter inNetworkStorageconstructor to enable collection-based mode. - New
NetworkStorageCollectionBasedConfig<T>class for configuring collection-based storage:getAllEnabled: Controls whethergetAllis allowed for collection-based storage (default:true).maxGetAllDocs: Maximum number of documents to fetch ingetAlloperations (default:10).defaultQuery: Default query function (QueryFn<T>) for filtering/ordering documents.
- New
QueryFn<T>typedef:Query<T> Function(Query<T> colRef)for custom query builders. - New
getQuerymethod inNetworkStoragefor querying collection-based storage with custom Firestore queries.
Sync Improvements
- [SyncManager]: Added
syncLocalWithNetworkOnFetchparameter (default:true) to control whether local storage should be synchronized with network data on fetch operations. - [SyncManager]: Added new
fetchAndSyncFromNetworkgetter that fetches data from the network and optionally clears and updates local storage to match. - [SyncedState]: The
refreshmethod now usesfetchAndSyncFromNetworkinstead ofallFromNetwork, ensuring local storage stays in sync with network data. - [SyncedState]: Changed
_paramsfromlate finaltolateto allow reassignment/reconfiguration.
Bug Fixes #
- [NetworkStorage.getAll]: Now returns an empty
IMap<String, T>if the Firestore document doesn't exist, instead of throwing a null error. - [NetworkStorage.writeBatchDelete]: Fixed return type to properly return
voidinstead of an unintended value.
Internal Changes #
- All
NetworkStoragemethods (update,transactionUpdate,writeBatchUpdate,delete,transactionDelete,writeBatchDelete,clear) now fully support collection-based mode. - Collection-based operations use
WriteBatchfor efficient bulk operations. - Added Firestore
withConvertersupport for type-safe document operations in collection-based mode.
0.2.7 #
Updated dependencies
0.2.6 #
Added new copyWith method to [StdObjParams].
0.2.5 #
Removed flutter_riverpod dependency. This should not be a Breaking Change, since none of the functionality actually depended on flutter_riverpod.
0.2.4 #
Added new refresh method in [SyncedState].
0.2.3 #
Fixed bug in [SyncedState]'s clear method, which now clears the state as well.
0.2.2 #
Fixed a bug in [SyncedState]'s update method, with sorting enabled, causing
the newly added last element in the sorted dataset, to not be visible in state.
0.2.1 #
Fixed a bug in [SyncedState]'s update method, with sorting enabled.
0.2.0 #
[Breaking Change]: Replaced [hive_flutter] with [hive_ce_flutter].
0.1.0 #
[Breaking Change]: Replaced Ref<Dataset<T>> in NotifierProviderRef<Dataset<T>> in [SyncedState].
0.0.1 #
Contain important classes like [LocalStorage], [NetworkStorage], [StdObj], [StdObjParams], [SyncManager], [Synced] etc.