Skip to content

Approach to share Signals between Windows? #4110

Closed Answered by reckel-jm
reckel-jm asked this question in Q&A
Discussion options

You must be logged in to vote

By studying the documentation, I found out that I can provide root context to a virtual DOM. Considering that I have a created Signal, I can pass it on to the virtual DOM like this:

let mydata: Signal<MyDataType> = use_signal(|| MyDataType::new());
let second_dom = VirtualDom::new(StartComponent).with_root_context(mydata);

Inside the second dom, I can than access the signal with use_context (and the correlating type):

let mydata: Signal<MyDataType> = use_context();

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by reckel-jm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant