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

Does listenToBeacons say no beacons here? #54

Open
barangungor opened this issue Oct 8, 2021 · 1 comment
Open

Does listenToBeacons say no beacons here? #54

barangungor opened this issue Oct 8, 2021 · 1 comment

Comments

@barangungor
Copy link

I have a problem wiht listenToBeacons. That's my code:

beaconEventsController.stream.listen((data) async {
print(data);
print('DATA');
print(_beacons.length);
_beacons.clear();
_beacons.add(json.decode(data));
print(_beacons);
}, onDone: () {
print('DONEEEEE');
}, onError: (error) {
print("Error: $error");
});

this stream's listen doesnt send data when there are no beacon. I should get data even if there are no beacons. How can i do that?

@baranacikgoz
Copy link

I had faced this question and find out stream's timeout feature can solve our problem. I've just changed the line starting with _beaconEventsController.stream...... to this;

_beaconEventsController.stream.timeout(const Duration(milliseconds: xxx),
        onTimeout: (_) {
      // No beacons found for xxx ms
    }).listen(
        (data) {
          // Didn't changed here
        },
        onDone: () {},
        onError: (error) {
          print("Error: $error");
        });

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

2 participants