Instawork / hyperview

Server-driven mobile apps with React Native

Home Page:https://hyperview.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Loading UI from device

roelve opened this issue · comments

Would it be possible to load screens from a directory on the phone rather than from a webadress? I only see some limited use cases for it but I was just wondering whether it is possible or not.

Hi @roelve , yes it is possible to this with a custom version of fetch that gets provided as a dependency to the Hyperview component. See docs here: https://hyperview.org/docs/reference_hyperview_component

In the demo, we write a custom fetch wrapper that adds some request headers to prevent caching. But theoretically, you can create an implementation that takes the request and responds to it by serving local files. Perhaps certain HTTP request paths could be mapped to local directories of static assets. You could even implement this as a fallback: you first always check for local/static assets, and if they're not found, make the request to your backend.

I hope that helps!

Thank you for your reply. The use case you mention to use it as a fallback is very interesting. I have a follow up question though, would loading UI from local files have a potential performance benefit or would that be negligible?

I can’t say for sure since I haven’t tested it, but generally local file lookup should be order of magnitudes faster than making a request over the network. So I expect the overhead to be pretty minimal compared to just going over the network.

Ok thanks! I suppose you can close this now.