updateAndSync method
Future<(T, DatumSyncResult<T> )>
updateAndSync({
- required T item,
- required String userId,
- DataSource source = DataSource.local,
- bool forceRemoteSync = false,
- DatumSyncOptions<
T> ? syncOptions, - DatumSyncScope? scope,
Updates an entity locally and immediately triggers a synchronization.
This is an alias for pushAndSync and is provided for semantic clarity. It's useful for operations that require immediate confirmation from the remote server.
Returns a tuple containing the locally saved entity and the sync result.
Implementation
Future<(T, DatumSyncResult<T>)> updateAndSync({
required T item,
required String userId,
DataSource source = DataSource.local,
bool forceRemoteSync = false,
DatumSyncOptions<T>? syncOptions,
DatumSyncScope? scope,
}) async {
_ensureInitialized();
// `push` handles both create and update, so this is equivalent to pushAndSync.
final savedItem = await push(item: item, userId: userId, source: source, forceRemoteSync: forceRemoteSync);
final syncResult = await synchronize(userId, options: syncOptions, scope: scope);
return (savedItem, syncResult);
}