pushAndSync method

Future<(T, DatumSyncResult<T>)> pushAndSync({
  1. required T item,
  2. required String userId,
  3. DataSource source = DataSource.local,
  4. bool forceRemoteSync = false,
  5. DatumSyncOptions<T>? syncOptions,
  6. 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);
}