rxdart icon indicating copy to clipboard operation
rxdart copied to clipboard

BehaviorSubject not cleaning error after added data

Open TercyoStorck opened this issue 3 years ago • 6 comments

I don't know why but when I add an error to BehaviorSubject and after add some data. It not cleaning any more the error. And I can't pass null to addError, So BehaviorSubject.hasError is always true.

TercyoStorck avatar Jun 17 '21 21:06 TercyoStorck

According to https://github.com/ReactiveX/rxdart/pull/560#discussion_r590585726 of @frankpepermans This behavior was changed since 0.27.0. Should we revert or keep this?

hoc081098 avatar Jun 18 '21 02:06 hoc081098

Well, this can be looked at from many different angles as always :/

Currently hasValue and hasError just mean: "did emit value/error at a certain point"

Maybe we do need to change it again...

So that hasError/hasValue get error/value only refer to the very last emission, whereas the handlers onError/onData trigger for each emitted item.

Then we could also rename them to be less ambiguous, I.e latestIsError/latestError and latestIsValue/lastValue?

frankpepermans avatar Jun 18 '21 04:06 frankpepermans

Well, this can be looked at from many different angles as always :/

Currently hasValue and hasError just mean: "did emit value/error at a certain point"

Maybe we do need to change it again...

So that hasError/hasValue get error/value only refer to the very last emission, whereas the handlers onError/onData trigger for each emitted item.

Then we could also rename them to be less ambiguous, I.e latestIsError/latestError and latestIsValue/lastValue?

I understood it. But i thinking it could have hasError like it was. All my forms using hasError to verify if is all ok. And now, is everything broke. =/

TercyoStorck avatar Jul 19 '21 12:07 TercyoStorck

Well, this can be looked at from many different angles as always :/

Currently hasValue and hasError just mean: "did emit value/error at a certain point"

Maybe we do need to change it again...

So that hasError/hasValue get error/value only refer to the very last emission, whereas the handlers onError/onData trigger for each emitted item.

Then we could also rename them to be less ambiguous, I.e latestIsError/latestError and latestIsValue/lastValue?

I'm afraid ValueStream will have too many getters :))

hoc081098 avatar Aug 06 '21 11:08 hoc081098

I understood it. But i thinking it could have hasError like it was. All my forms using hasError to verify if is all ok. And now, is everything broke. =/

Same here, the behaviour has changed and some key behavior on all my apps are now broken, it's kind of a big deal to me. For me the error/hasError should report the status of the LATTEST value kept, otherwise it's not very usefull. So when a new value is added, error should be cleaned, and when an error is added, value should be cleaned.

Nico04 avatar Dec 09 '21 16:12 Nico04

Any updates?

TercyoStorck avatar Feb 15 '22 19:02 TercyoStorck

any update about this? I'm curious how to identify if the last emitted value was an error or value? Since and last emitted error and last emitted value stored within the value stream and there is nothing that can define which one of these 2 was last

TatsuUkraine avatar Jun 12 '23 13:06 TatsuUkraine

In my case, as I used rxdart just for basic usage of BehaviorSubject , I ended up creating my own basic package : value_stream

Nico04 avatar Jun 12 '23 13:06 Nico04

@hoc081098 one of the possible (non-breaking) solutions, it would be awesome if the upcoming release will have anything that helps to identify what last data type valuestream has. Thanks!

TatsuUkraine avatar Jun 12 '23 14:06 TatsuUkraine

Thank @TatsuUkraine, I have created https://github.com/ReactiveX/rxdart/pull/729, but the method names need to be discussed.

hoc081098 avatar Jun 20 '23 09:06 hoc081098

@hoc081098 naming looks good to me

TatsuUkraine avatar Jun 20 '23 09:06 TatsuUkraine

A dev release will be published in this week 😊.

hoc081098 avatar Jun 22 '23 13:06 hoc081098

@hoc081098 just curious, when these changes may go live?

TatsuUkraine avatar Jul 11 '23 18:07 TatsuUkraine

@TatsuUkraine please try https://pub.dev/packages/rxdart/versions/0.28.0-dev.0 🙏

hoc081098 avatar Jul 26 '23 06:07 hoc081098

@hoc081098 hello, do you know when this change may go to stable release?

TatsuUkraine avatar Dec 06 '23 11:12 TatsuUkraine

@hoc081098 hi, any updates on when these changes my go into stable?

TatsuUkraine avatar Jan 25 '24 16:01 TatsuUkraine

@hoc081098 hi, any updates on when these changes my go into stable?

Hi, I will look into it 🙏

hoc081098 avatar Jan 27 '24 06:01 hoc081098