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

[Android][1.9.0] Last value sent twice since onValueChangedStream => onValueReceived #419

Closed
charmosz opened this issue Jul 24, 2023 · 5 comments

Comments

@charmosz
Copy link

charmosz commented Jul 24, 2023

Since the change onValueChangedStream => onValueReceived it seems the last value is sent twice. Do I have something else to change ?

Before :

await charMeasure?.setNotifyValue(true);

_notifySubscription = charMeasure?.onValueChangedStream.listen((value) {
if (value.isNotEmpty) {
print('sending ${value.toString()}');
}
},
);

await charMeasure?.read();

After :

await charMeasure?.setNotifyValue(true);

_notifySubscription = charMeasure?.onValueReceived.listen((value) {
if (value.isNotEmpty) {
print('sending ${value.toString()}');
}
},
);

await charMeasure?.read();
@chipweinberger
Copy link
Collaborator

can you clarify what you mean? do you have logs?

@charmosz
Copy link
Author

On the device I know I have 11 values. In the first case when I trigger read() I have 11 logs, one for each value. In the second case I have 12 logs, the last one is printed twice.

@chipweinberger
Copy link
Collaborator

chipweinberger commented Jul 24, 2023

I think this is expected because you are calling await charMeasure?.read();

When you call await charMeasure?.read(), it causes onValueReceived to get the value again. This is the reason the variable was renamed -- in order to make this behavior more clear.

Are you using Android or iOS?

@chipweinberger
Copy link
Collaborator

chipweinberger commented Jul 24, 2023

This is how it has always worked on IOS. But you are right android used to work differently. I should have noticed this and put it in the ChangeLog as a breaking change.

The problem is iOS does not differentiate between manual reads and notification reads. They are all the same -- we cannot tell them apart. On android manual reads and notification reads are separate callbacks.

In the recent changes, android now behaves the same way as iOS. i.e. read() causes another value to appear on onValueReceived. The goal is to make both platforms behave the same way -- so we have no choice but to make Android not differentiate either.

@charmosz
Copy link
Author

Ok thanks for the explanation. I think it's a good idea to make both platforms work the same way.
And for my specific needs I will find a way to manage the fact that the last value is retrieved twice.

@chipweinberger chipweinberger changed the title Last value sent twice since onValueChangedStream => onValueReceived [Android][1.9.0] Last value sent twice since onValueChangedStream => onValueReceived Jul 24, 2023
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