Open dermetfan opened 5 years ago
The ability to get a reference to the value was removed because it could cause a RefCell
borrow violation (in the old version) under some special conditions, and that code was really complex and
hard to debug. The new version of Signal
doesn't even have that, it's just a function:
pub struct Signal<T>(Arc<dyn Fn() -> T + Send + Sync>);
It's much simpler now, but AFAIK you can't return a reference to closure data. Maybe it can be done with some hack I yet have to research. For now you have to wrap your types on Arc
or similar to prevent the cloning (or make them cheap to clone). If you're using strings you may want to look into string interning libraries.
Recently
Signal::sample_with()
was removed. I was unable to find an alternative to get a reference to the signal's value. This is important to me because I storeString
s and other big types in my text editor project.Is there really no way to get a reference or should I go RTFM?