validate static method

Stream<bool> validate(
  1. List<TwoWayBinding<Object>> bindings, {
  2. bool initialValue = false,
})

Perform a validation against the provided bindings.

Implementation

static Stream<bool> validate(
  List<TwoWayBinding<Object>> bindings, {
  bool initialValue = false,
}) =>
    Rx.combineLatest<Object?, bool>(
      bindings.map((binding) => binding.stream),
      (values) {
        var isValid = true;
        values.asMap().forEach((index, value) {
          isValid &= value == bindings[index].value;
        });

        return isValid;
      },
    ).onErrorReturn(false).shareValueSeeded(initialValue).asBroadcastStream();