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

Feat: add global context functions #1572

Merged
merged 3 commits into from
Jan 4, 2024
Merged

Feat: add global context functions #1572

merged 3 commits into from
Jan 4, 2024

Conversation

jkelleyrtp
Copy link
Member

Add functions like window() and router() to allow dynamically grabbing global contexts without have to use the hook variants.

Deprecates the existing hook variants to discourage folks from adding more noise to their codebases.

Add functions like window() and router() to
allow dynamically grabbing global contexts
without have to use the hook variants.

Deprecates the existing hook variants to
discourage folks from adding more noise
to their codebases.
@jkelleyrtp jkelleyrtp requested a review from ealmloff October 23, 2023 20:26
Copy link
Member

@ealmloff ealmloff left a comment

Choose a reason for hiding this comment

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

Overall, this is much nicer, but there are definitely some caveats. If the API changes to call some function directly instead of using a factory, it can be more difficult to use in threads or tokio futures. For example, the eval hook changes from a function that creates an eval object to a function that directly evaluates some javascript that needs to be within the dioxus runtime. That will make calling the function from a tokio runtime like this impossible:

tokio::spawn(async move {eval("console.log")});

@jkelleyrtp jkelleyrtp added this to the 0.5 Release milestone Oct 25, 2023
@ealmloff ealmloff added breaking This is a breaking change desktop Suggestions related to the desktop renderer router Related to the router implementation tweak Small changes to improve experience labels Oct 30, 2023
@jkelleyrtp jkelleyrtp merged commit ea0c39b into master Jan 4, 2024
0 of 10 checks passed
@jkelleyrtp jkelleyrtp deleted the jk/global-window-fun branch January 4, 2024 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking This is a breaking change desktop Suggestions related to the desktop renderer router Related to the router implementation tweak Small changes to improve experience
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants