ensure method

  1. @override
Future<void> ensure(
  1. FutureOr<void> fn()?
)
override

Ensures the signal is initialized and runs the given function.

Parameters:

  • fn: Optional function to run after ensuring initialization

Returns: A Future that completes when the operation is done

Implementation

@override
Future<void> ensure(FutureOr<void> Function()? fn) async {
  if (!hasInitialized) await _load();

  await fn?.call();
}