Closed lukechu10 closed 3 years ago
Temporary workaround in #34
The way this would work would probably use slab
or slotmap
so that the keys are Copy
. Lifetimes might be tricky to get right but the idea should be that all state created using Signal::new
should have the same lifetime and destroyed with component. Passing state up the component tree should be done using props.
If we get the lifetime annotations right, it should be guaranteed by the compiler that Signal
s are never passed up into a component with a longer lifetime. If that is not possible, runtime checks will have to suffice as it should be a relatively rare scenario.
Currently,
create_signal
and the likes returnRc
s. The user must clone them into which ever scope they are used, which is veyr unergonomic. These hooks should create state with the same lifetime as the enclosing component.Unfortunately, this also means that the simplicity of a single function is no longer possible for defining new components. A proc-macro-attribute could potentially help with this.