Instawork / hyperview

Server-driven mobile apps with React Native
https://hyperview.org
MIT License
1.22k stars 57 forks source link

Document fragments #794

Open karneaud opened 7 months ago

karneaud commented 7 months ago

Been trying to use document fragments to switch between <screen> but kept getting

Network error: Failed to load request

Then I came across this...

NOTE: Document fragments do not currently work with navigation behaviors, just update behaviors. Future versions of the Hyperview client will support document fragments with navigation behaviors.

In the "document fragment" format, href is an element id prepended by a #. The id must refer to an element in the current document.

For example, assume the following doc is loaded from https://mysite.com/home:

<doc xmlns="https://hyperview.org/hyperview">
  <screen>
    <body>
      <text href="#secondScreen">Hello</text>
    </body>
  </screen>
  <screen id="secondScreen">
    <body>
      <text>Second screen!</text>
      <text href="/test">Test</text>
    </body>
  </screen>
</doc>

When the user presses "Hello", the content for the next screen will be loaded from the doc:

<screen id="secondScreen">
  <body>
    <text>Second screen!</text>
    <text href="/test">Test</text>
  </body>
</screen>

I'm trying to understand what is being said here. Is it that document fragments cannot work in <Navgiation/> scenarios? If so how does this work? How can this work?

flochtililoch commented 7 months ago

Hi @karneaud Thanks for bringing this to our attention. The scenario you tried implementing is indeed not supported; instead we suggest to provide the content of your second screen via another endpoint and refer to it via a URL. I've updated the docs in #795 to remove the ambiguous statements, let me know if the docs makes more sense now!