OptimisticUpdater<T, P> typedef

OptimisticUpdater<T, P> = T? Function(P params, T? oldData)

Optimistic update transformation function updating cached data in BloomData prior to network response.

Given the mutation params and existing cached data oldData for BloomMutation.optimisticKey, returns the projected new data of type T?. If the mutation subsequently fails, BloomMutation automatically rolls back the cache to its pre-mutation snapshot.

OptimisticUpdater<List<Task>, Task> addOptimisticTask = (newTask, currentTasks) {
  return [...?currentTasks, newTask];
};

Implementation

typedef OptimisticUpdater<T, P> = T? Function(P params, T? oldData);