Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question]: Any thoughts on difference between ignoreChange and distinct? #241

Open
Fnll opened this issue Sep 16, 2022 · 0 comments
Open

Comments

@Fnll
Copy link

Fnll commented Sep 16, 2022

Hi, new dart beginner here. As far as I can see, the widget update process will spawn a stream which could be cancelled both when ignoreChange implemented, and distinct is set true. I'm not seeing any difference using one of the two, and confused about it. Not sure if there is any consideration I've missed?

  void _createStream() {
    _stream = widget.store.onChange
        .where(_ignoreChange)
        .map((_) => widget.converter(widget.store))
        .transform(StreamTransformer.fromHandlers(
          handleError: _handleConverterError,
        ))
        // Don't use `Stream.distinct` because it cannot capture the initial
        // ViewModel produced by the `converter`.
        .where(_whereDistinct)
        // After each ViewModel is emitted from the Stream, we update the
        // latestValue. Important: This must be done after all other optional
        // transformations, such as ignoreChange.
        .transform(StreamTransformer.fromHandlers(
          handleData: _handleChange,
        ))
        // Handle any errors from converter/onWillChange/onDidChange
        .transform(StreamTransformer.fromHandlers(
          handleError: _handleError,
        ));
  }
@Fnll Fnll changed the title Any thoughts on difference between ignoreChange and distinct? [Question]: Any thoughts on difference between ignoreChange and distinct? Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant