doWhenOpened<T> method

Future<T> doWhenOpened<T>(
  1. FutureOr<T> fn(
    1. QueryExecutor e
    )
)

Performs the async fn after this executor is ready, or directly if it's already ready.

Calling this method directly might circumvent the current transaction. For that reason, it should only be called inside drift.

Implementation

Future<T> doWhenOpened<T>(FutureOr<T> Function(QueryExecutor e) fn) {
  return executor.ensureOpen(attachedDatabase).then((_) => fn(executor));
}