Remove Rc and RefCell from Signal? #600
Labels
A-reactivity
Area: reactivity and state handling
C-enhancement
Category: new feature or improvement to existing feature
Currently signals store the value in an Rc, requiring an extra memory allocation, and getting the value requires to clone the signal rather than getting a reference.
This seems a poor design since the Rc is unnecessary a lot of times (e.g. if the value is an integer or the value is never cloned) and the user can always create a Signal<Rc> if they want it.
Also it's obviously much more efficient to just get a reference to a value rather than cloning it with get() (although the user must be careful to not do anything that could set the signal while the reference is held) so either get() could return a reference or a get_ref() function could be provided; again, the user can clone the value themselves if they so desire.
So the options could be to either get rid of Rc on Signal or create a parallel set of Signal types without Rc.
RefCell is also not ideal in case the value is an integer, so it might be nice to have the user specify the cell type and support both RefCell and Cell.
There's also the problem that Signal doesn't support multithreading, which requires to solve this problem and also provide a way to specify an Arc-based signal emitter instead of the Rc-based one.
The text was updated successfully, but these errors were encountered: