when function

ReactionDisposer when (
  1. bool predicate(
    1. Reaction
    ),
  2. void effect(
      ),
    1. {String name,
    2. ReactiveContext context,
    3. int timeout,
    4. void onError(
      1. Object,
      2. Reaction
      )}
    )

    A one-time reaction that auto-disposes when the predicate becomes true. It also executes the effect when the predicate turns true.

    You can read it as: "when predicate() turns true, the effect() is executed."

    Returns a function to dispose pre-maturely.

    Implementation

    ReactionDisposer when(bool Function(Reaction) predicate, void Function() effect,
            {String name,
            ReactiveContext context,
            int timeout,
            void Function(Object, Reaction) onError}) =>
        createWhenReaction(context ?? mainContext, predicate, effect,
            name: name, timeout: timeout, onError: onError);