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

onStateChanged should emit state when listened to #21

Open
pauldemarco opened this issue Sep 6, 2017 · 0 comments
Open

onStateChanged should emit state when listened to #21

pauldemarco opened this issue Sep 6, 2017 · 0 comments

Comments

@pauldemarco
Copy link
Owner

Having to do a lot of this:

    // Immediately get the state of FlutterBlue
    _flutterBlue.state.then((s) {
      setState(() {
        state = s;
      });
    });
    // Subscribe to state changes
    _stateSubscription = _flutterBlue.onStateChanged().listen((s) {
      setState(() {
        state = s;
      });
    });

By having onStateChanged() always return current state when listened to, we can avoid the extra then call.

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