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

Transient inconsistent state behaviour #211

Closed
ChizobaAmadi opened this issue Mar 8, 2024 · 3 comments
Closed

Transient inconsistent state behaviour #211

ChizobaAmadi opened this issue Mar 8, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@ChizobaAmadi
Copy link

I was debugging an issue and observed that an async signal can temporarily propagate an invalid state where isCompleted is false and the data is set. This is because the library sets the value before setting the _completer:

 void setValue(T value) {
    this.value = AsyncState.data(value);
    if (_completer.isCompleted) _completer = Completer<bool>();
    _completer.complete(true);
  }

Widget:

 Watch((context) {
          final activities = viewStateHandler.activities;
          final panels = viewStateHandler.sectionPanels;

          print("isCompleted: ${activities.isCompleted} "
              "type: ${activities.value.runtimeType} "
              "hasValue: ${activities
              .get()
              .hasValue}");

Logs
flutter: isCompleted: false type: AsyncLoading<Map<String, List>> hasValue: false
flutter: isCompleted: false type: AsyncData<Map<String, List>> hasValue: true

After a hot reload, I can see isCompleted is set to true;

I'm not sure if this is a desired behaviour, as it can lead to errors for anyone checking isCompleted instead od using the map function.

@rodydavis
Copy link
Owner

I actually think I can remove the completer on future versions because of future signal not extending stream signal.

There is a conflict on the completed vs the stream.

Thanks for finding this!

@rodydavis rodydavis added the bug Something isn't working label Mar 9, 2024
@ChizobaAmadi
Copy link
Author

Ok ! Sounds good. Really nice package btw

@rodydavis
Copy link
Owner

This should have fixed it:
#219

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants