Skip to content

How do you access contexts from views sent through channels? #3400

Answered by gbj
aiyoux asked this question in Q&A
Discussion options

You must be logged in to vote

The problem here is mostly just that context isn't available in event handlers, I think.

The short answer: Use Owner::current() to get the current owner at some point (i.e., in the body of the SendsMessage component, and use owner.with(|| { ... }) or OwnedView::new_with_owner to set it as the owner for the view you're sending through the channel.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@aiyoux
Comment options

Answer selected by aiyoux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants