是否有类似于仅适用于 1 个流的 CombineLatest 的功能?

Is there function similar to CombineLatest which only for 1 stream only?

我是 Rxdart 的新手,我已经为 2 种流尝试了 Combinelatest2,例如:

Observable<String> get email => _user.stream.transform(validateEmail);
  Observable<String> get password => _password.stream.transform(validatePassword);
  Observable<bool> get submitValid => Observable.combineLatest2(email, password,
          (checkEmail, checkPassword) => true);

在我的 validateEmail 和 validatePassword 中:

final validateEmail= StreamTransformer<String, String>.fromHandlers(
      handleData: (user, sink){
        if(EmailValidator.validate(email)){
          sink.add(email);
        }else{
          sink.addError("email wrong Format!!");
        }
      }
  );

final validatePassword = StreamTransformer<String, String>.fromHandlers(
      handleData: (password, sink){
        if(password.length > 2){
          sink.add(password);
        }else{
          sink.addError("Password must be at least 3 characters");
        }
      }
  );

这是我主页屏幕上的按钮:

Widget submitButton(ChangePasswordBloc bloc){
    return StreamBuilder(
//      stream: bloc.submitValid,
      builder: (context, snapShot){
        return RaisedButton(
          child: Text("Change Password"),
          color: Colors.blue[400],
          onPressed: ()  {
            if(snapShot.hasData){

            }else{
              return null;
            }
          },
        );
      },
    );
  }

如果使用 combinelatest2,我可以从 observable 获得 2 种发射的变化,我可以打开/关闭我的按钮,但如果我只想观察电子邮件,我该怎么做?如果来自电子邮件的发射器是正确的,那么提交按钮是打开的,反之亦然

您可以使用地图来做到这一点。您可以映射电子邮件和 return 布尔值,而不是组合电子邮件和密码。

Observable<bool> get submitValid => email.map((email) => true);