pushAndSync method
Future<(T, DatumSyncResult<T> )>
pushAndSync({
- required T item,
- required String userId,
- DataSource source = DataSource.local,
- bool forceRemoteSync = false,
- DatumSyncOptions<
T> ? syncOptions, - DatumSyncScope? scope,
Saves an entity locally and immediately triggers a synchronization.
This is useful for operations that require immediate confirmation from the
remote server. It combines push() and synchronize() into a single call.
Returns a tuple containing the locally saved entity and the sync result.
Implementation
Future<(T, DatumSyncResult<T>)> pushAndSync({
required T item,
required String userId,
DataSource source = DataSource.local,
bool forceRemoteSync = false,
DatumSyncOptions<T>? syncOptions,
DatumSyncScope? scope,
}) async {
_ensureInitialized();
final savedItem = await push(item: item, userId: userId, source: source, forceRemoteSync: forceRemoteSync);
final syncResult = await synchronize(userId, options: syncOptions, scope: scope);
return (savedItem, syncResult);
}