-
I've been going through the Leptos counter examples, both v0.6 and master. pub struct SignalVec<T>
where
T: 'static,
{
inner: RwSignal<Vec<RwSignal<T>>>,
} Implementing But how would I implement pub fn push(&self, value: T) {
self.inner.update(|inner| {
inner.push(create_rw_signal(value));
});
}
pub fn pop(&self) -> Option<T> {
self.inner.update(|inner| {
let signal = inner.pop();
// And now what?
// signal.dispose_and_take_underlying_value()
});
} Is this simply a missing API, or is there a deeper reason as to why this would not work? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Beta Was this translation helpful? Give feedback.
.try_update
returns a value, so I guess you could.get()
the signal. No, there's not a "consume the signal and give me the value" function, because of the arena-based (rather than reference-counted) storage -- there's no guarantee that you don't have other copies of the innerRwSignal
lying around so it's not safe to consume the value unless it's disposed. (Whether disposing of a signal should give you its inner value is an interesting question, and not the bad idea, but the first time it's been suggested.)