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

What would be a good way to trigger a tree update but from outside of XML? #774

Open
Invertisment opened this issue Dec 27, 2023 · 3 comments
Assignees

Comments

@Invertisment
Copy link

Invertisment commented Dec 27, 2023

For instance in HTMX they have hx-swap-oob and you can instantiate that raw HTML snippet to swap it into the DOM according to rules of hx-swap-oob.
This allows to morph the DOM in some weird ways.
It doesn't need to be completely generic but it would work even if I could take a single XML string and swap it into an element from outside.

What I try to understand if it's possible to use useRef to hold a reference to some kind of handler inside of Hyperview component where I could just submit small snippet of new XML to (not whole reload). And I'd expect this XML to run and change something in the existing app tree.
For instance I could have a fully rendered Hyperview component but then I'd want to handle a callback from the other part of React application that's not Hyperview -- then I could submit XML to some part of the app to be rendered on the spot.

If this is hard to do then my things may also be implementable by firing events. But to fire the events I'd have to fire them to somewhere and I'd still expect to then use something like useRef to take the Hyperview instance and fire the events into it (for instance if I get a push notification).

@Invertisment Invertisment changed the title What would be a good way to achieve something similar to hx-swap-oob? What would be a good way to trigger something similar to hx-swap-oob but from outside? Dec 27, 2023
@Invertisment Invertisment changed the title What would be a good way to trigger something similar to hx-swap-oob but from outside? What would be a good way to trigger an action but from outside? Dec 27, 2023
@Invertisment Invertisment changed the title What would be a good way to trigger an action but from outside? What would be a good way to trigger an action but from outside of DOM? Dec 27, 2023
@Invertisment Invertisment changed the title What would be a good way to trigger an action but from outside of DOM? What would be a good way to trigger a tree update but from outside of XML? Dec 27, 2023
@Invertisment
Copy link
Author

After looking into the way it's designed around navigation I think that the easiest way to do this is to just rerender whole page while an app would be multiple pages in size.
In other words the current design forces the user to fetch one screen at a time and it forces to rely on external routing implementation.

But then it defeats the purpose to talk about how you can represent the whole app with one XML file because now you need to have a file per screen -- just like in HTML.

@adamstep
Copy link
Contributor

adamstep commented Jan 3, 2024

Hi @Invertisment , I'm not sure I quite follow. Can you describe what you're trying to achieve in an app that you've built? We don't have an equivalent to hx-swap-oob. Typically if we want to update multiple parts of a screen, we either:

  • update the entire screen
  • use events to trigger multiple requests to update individual areas of the screen

@adamstep adamstep self-assigned this Jan 3, 2024
@Invertisment
Copy link
Author

I want to trigger an event from outside of Hyperview component

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

No branches or pull requests

2 participants