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

Enhance value assignment equality for IterableSignals #243

Open
leoafarias opened this issue Apr 16, 2024 · 5 comments
Open

Enhance value assignment equality for IterableSignals #243

leoafarias opened this issue Apr 16, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@leoafarias
Copy link
Contributor

The current implementation of the equality check in the IterableSignal class (which ListSignal extends) compares the iterable references instead of comparing the actual values of the iterable.

This behavior is expected when assigning a list using signal, but in my opinion using listSignal, or some of the other IterableSignals, this should be handled.

final value1 = [1, 2, 3];
final value2 = [1, 2, 3];

final list = listSignal(value1);

effect(() {
  print('list changed');
  print(list.value);
});

list.value = value2;

// prints: list changed
// prints: [1,2,3]

Suggestions

  1. Adapt our equality check within IterableSignal to align more with how collection functions are handled, thus ensuring a comparison based on the value.
  2. Allow the provision of a specific equality function for each iterable signal function, enabling more flexible and customised evaluation.
@rodydavis rodydavis added the enhancement New feature or request label Apr 16, 2024
@rodydavis
Copy link
Owner

Do you mean you want ListSignal to compare with DeepCollectionEquality?

@leoafarias
Copy link
Contributor Author

Yes, but if you don't want to bring as a dependency, maybe we can create an equivalent. Let me know what makes sense, and I can give a try on a PR.

@rodydavis
Copy link
Owner

I'm trying to hold off adding dependencies as long as possible to maximize compatibility with projects.

I think having something equivalent would be a great addition!

@leoafarias
Copy link
Contributor Author

I agree, will create a PR for you to review if it makes sense.

@rodydavis
Copy link
Owner

Sounds great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants