Skip to content

Conversation

@davidmartos96
Copy link

Fixes #394

The problem was that the equality in AsyncState wasn't being done properly when going from AsyncDataReloading to AsyncData because as a side effect to the reloading state being a subclass of AsyncData. I've added the equality with the 3 loading states. I think that would be the correct solution for the exhaustiveness.

Additionally, while creating a test, I've noticed that a future signal .reload() wasn't propagating the reload future because the internal Completer wasn't being recreated.

image

For this, would it be ok to remove the batch? I've added it because it is how it's written in setValue, but I'm not sure it's needed.

@alfonsovgs
Copy link

@davidmartos96 The same thing happened to me, how did you solve it without that change?

@davidmartos96
Copy link
Author

@alfonsovgs I wasn't able to solve it without this. @rodydavis mentioned in the linked issue that it works as expected though. To me it makes much more sense the behavior with the proposed changes.

@alfonsovgs
Copy link

@alfonsovgs I wasn't able to solve it without this. @rodydavis mentioned in the linked issue that it works as expected though. To me it makes much more sense the behavior with the proposed changes.

I think the same. For now, I did this and it works, as I understand Signals a little better.

class NonDistinct<T> {
  const NonDistinct(this.value);

  final T value;

  @override
  bool operator ==(Object other) => false;

  @override
  int get hashCode => identityHashCode(this);
}
final currentLocation = futureSignal<NonDistinct<LatLng?>>(() async {
  await Future.delayed(Durations.short4);
  return LatLng(40.73061, -73.9);
}, debugLabel: 'currentLocation');

@davidmartos96
Copy link
Author

I still believe something else could be changed. Even with the equality added, the signal isn't properly updating when going from reloading to data.

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.

Future signal refresh/reload state is still loading even when the data is returned

2 participants