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

Account for existing _forceLastValidStreamState when rebuilding #142

Merged

Conversation

kuhnroyal
Copy link
Contributor

@kuhnroyal
Copy link
Contributor Author

There are 2 test failures in the persistence test but that has to be unrelated.

@marcglasberg
Copy link
Owner

Yes, the persistence code is correct, but the persistence tests that are failing because they depend on precise timing. I was hoping to think of a way to make them more stable, but maybe they need to be removed.

@marcglasberg
Copy link
Owner

Ideally we should first create a failing test that was fixed by this change.

@kuhnroyal
Copy link
Contributor Author

Ideally we should first create a failing test that was fixed by this change.

I agree but that needs to be a widget test. Will see what I can do.

@marcglasberg
Copy link
Owner

Yes, if the problem is in the didUpdateWidget you need a widget test. Thank you!!

@kuhnroyal
Copy link
Contributor Author

I added a test case which fails without the change.

I also needed to make one more change in the StoreConnector. Without setting the initial state as _mostRecentValidState, it could still fail if shouldUpdateModel returns false for the first state change.
In that case _mostRecentValidState would still be null in line https://github.com/marcglasberg/async_redux/blob/master/lib/src/store_connector.dart#L477

@kuhnroyal kuhnroyal marked this pull request as ready for review October 6, 2022 13:37
* currently converter parameter does not work with shouldUpdateModel
@kuhnroyal
Copy link
Contributor Author

I added a test workflow, if you want to enable Github Actions.

@kuhnroyal
Copy link
Contributor Author

Additionally I found with my test that the converter does not work together with shouldUpdateModel.
The incorrect state is passed to the converter function in https://github.com/marcglasberg/async_redux/blob/master/lib/src/store_connector.dart#L600

@kuhnroyal
Copy link
Contributor Author

We could an an assert or change the converter function parameter, both changes are breaking.

@marcglasberg
Copy link
Owner

What changes to the converter function do you recommend?

@@ -378,6 +378,12 @@ class _StoreStreamListenerState<St, Model> //
}

_computeLatestModel();
if (widget.shouldUpdateModel != null) {
// The initial state has to be valid at this point.
// This is need so that the first stream event
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo here. "This is needed"

@kuhnroyal
Copy link
Contributor Author

Fixed the typo.

What changes to the converter function do you recommend?

I would say, release the fix as a patch and change the parameter of the converter function in a breaking release.
So far nobody seems to have this problem, I hardly ever use the converter and only noticed this with the test case.

@marcglasberg marcglasberg merged commit 0ecedd6 into marcglasberg:master Oct 10, 2022
@marcglasberg
Copy link
Owner

@kuhnroyal Your fix is published in version 17.0.1. Thank you!

@kuhnroyal kuhnroyal deleted the fix/should-update-model-rebuild branch October 10, 2022 08:32
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

Successfully merging this pull request may close these issues.

None yet

2 participants