Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

render_temporarily_to() helper #303

Merged
merged 3 commits into from
Nov 23, 2021

Conversation

alsuren
Copy link
Contributor

@alsuren alsuren commented Nov 22, 2021

As I mentioned in https://discord.com/channels/820400041332179004/821489793258487839/912364912624418846 I was having problems with things not getting dropped when gradually converting an existing app to use sycamore.

This function is intended to be used for injecting an ephemeral sycamore view into a non-sycamore app
(for example, a file upload modal where you want to cancel the upload if the modal is closed).
You should only use this function while refactoring your app, and you should aim to have a single
call to [render] or [render_to] at the top level of your app long-term.

Using this function did solve my problems.

Copy link
Member

@lukechu10 lukechu10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution. Just a few nitpicks.

///
/// _This API requires the following crate features to be activated: `dom`_
#[must_use = "please hold onto the ReactiveScope until you want to clean things up, or use render_to() instead"]
pub fn render_temporarily_to(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is the right name to use here. How about something like render_get_scope?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have pushed a change to use render_get_scope.

Other potential names include render_and_get_scope render_and_return_scope render_to_scope mount_and_get_scope. Shout if you prefer any of those.

packages/sycamore/src/generic_node/dom_node.rs Outdated Show resolved Hide resolved
@lukechu10
Copy link
Member

lgtm. thanks!

@lukechu10 lukechu10 merged commit 63ec424 into sycamore-rs:master Nov 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants