call method

Effect call(
  1. void action(), {
  2. bool guard()?,
  3. int? take,
  4. void onUncaughtError(
    1. Object error,
    2. StackTrace stackTrace
    )?,
})

Defines an explicit manifest Effect attached to this node.

  • Skips initial evaluation (0 runs upon construction/mount).

  • Executes action in an untracked environment when this node mutates.

  • If guard is provided and returns false, execution is skipped and take tickets are preserved.

  • If take is provided, executes at most take times then automatically deactivates (Early Teardown).

  • If onUncaughtError is provided, it is invoked when an uncaught exception is thrown in action or guard.

  • action: The untracked callback to invoke upon mutation.

  • guard: Optional boolean predicate gating execution and preserving tickets when false.

  • take: Optional limit on execution count before automatic deactivation.

  • onUncaughtError: Optional error recovery handler.

Requires:

  • If take is provided, it must be greater than or equal to 0.

Ensures:

  • Returns a unary manifest Effect bound to this node.

Examples

final counter = blooming(0);
final effect = counter.bloom.effect(() {
  analyticsService.logCounter(untracked(counter.bloom));
});

Implementation

@pragma('vm:prefer-inline')
Effect call(
  void Function() action, {
  bool Function()? guard,
  int? take,
  void Function(Object error, StackTrace stackTrace)? onUncaughtError,
}) =>
    Effect.unary(
      _target,
      action,
      guard: guard,
      take: take,
      onUncaughtError: onUncaughtError,
    );