Instawork / hyperview

Server-driven mobile apps with React Native

Home Page:https://hyperview.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Invertisment opened this issue · comments

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).

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.

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

I want to trigger an event from outside of Hyperview component