Currently dealing with signals with collections as values is a bit painful.
Let us take a very simple example:
final numbers = Signal([1, 2]);
// you may expect this to work
numbers.value.add(3);
// but the `numbers` signal will not update and won't notify listeners because you're modifying the value of its instance directly
// instead you have to provide a new instance
numbers.value = [...numbers.value, 3];
This is the same behaviour present in ValueNotifier by Flutter.
Proposal
In SolidJS there is an object called Store, a store is a collection of Signals.
What this mean is that each value of the Store is a Signal itself, and you can listen to each one individually.
In solidart I don't think this is needed because it may add an extra complexity and the goal of solidart is to stay simple.
Instead I'd propose to create 3 new kind of signals:
ListSignal, to interact with a list of objects
SetSignal, to interact with a set of objects
MapSignal, to interact with a map of objects
The previous example will become as simple as:
final numbers = ListSignal([1, 2]);
numbers.add(3);
This will make solidart even easier and will give a better developer experience for its users.
Problem
Currently dealing with signals with collections as values is a bit painful. Let us take a very simple example:
This is the same behaviour present in
ValueNotifier
by Flutter.Proposal
In SolidJS there is an object called
Store
, a store is a collection ofSignal
s. What this mean is that each value of theStore
is aSignal
itself, and you can listen to each one individually.In solidart I don't think this is needed because it may add an extra complexity and the goal of solidart is to stay simple.
Instead I'd propose to create 3 new kind of signals:
ListSignal
, to interact with a list of objectsSetSignal
, to interact with a set of objectsMapSignal
, to interact with a map of objectsThe previous example will become as simple as:
This will make solidart even easier and will give a better developer experience for its users.