ever method

RxReaction ever(
  1. void callback(
    1. T
    ), {
  2. bool condition(
    1. T
    )?,
})

callback is called every time that the Rx<T> changes.

If condition is not null the callback only is called if condition returns true.

Implementation

RxReaction ever(void Function(T) callback, {bool Function(T)? condition}) {
  // ignore: cancel_subscriptions
  final StreamSubscription subscription = stream.listen((event) {
    if (condition != null) {
      if (condition(event)) {
        callback(event);
      }
    } else {
      callback(event);
    }
  });
  return RxReaction(subscription, null);
}