Local JSON support related
See original GitHub issueSome people have requested local JSON feature. I have some concerns on this. But I also see some benefits. And overall, I think it’s worth discussing.
Possible solutions
There can be two solutions to this:
Approach 1. OPEN THE FILE DIRECTLY
Just use the internal method to directly open a JSON file from the bundle and draw it to the view.
Approach 2. SET UP AN IN-APP WEB SERVER
Set up an in-app web server and serve local files through the web server. (You could access them using something like local://
or localhost://
or something like that) This may sound convoluted compared to Approach 1, but I think it’s interesting in its own way. More on this below.
Current status
There have been a couple of pull requests for this. I took a look at them and categorized them into these categories:
-
Approach 1
-
Approach 2
Benefits
The obvious benefit is you can run your app offline. This is great, and some people have asked for this. Also you can quickly develop locally if you have a local JSON.
Concerns
My concern is just that I wasn’t envisioning this kind of usage when I was building Jasonette. It may look like just an innocent little feature, but I think it may have larger implication than that, going forward.
Until now Jasonette has been fully cloud based, therefore easy to understand–You simply add a URL and you have an app.
However once we support this, we have no reason not to support all kinds of other offline features. So it’s not just a matter of “let’s add this little feature”, we will need to commit to this direction. With the current thin client approach, we can easily scale to other platforms since everything is cloud based, but starting to support local may mean this may be difficult. (Then again, even desktop web browsers have localhost features, so maybe it’s workable, i don’t know) But this is just my opinion based on my gut feeling. That’s why I would love to hear thoughts.
Questions & Discussion
-
I do think we may need to support this local feature at some point. It’s just a matter of whether we should do it now or not. What are your thoughts on “support local now” vs. “think about it later”? Maybe it’s worth a try to support it now and see how it goes?
-
The web server approach by @copongcopong caught my interest because this feels like it could enable many other types of usage for Jasonette. Serving local files is just one usage, but what excites me is when you have a web server running, you can serve to the outside world as well. I like to imagine things so I could think of some weird and exciting use cases. I don’t know yet what this would mean but I feel like there’s something there. Any thoughts on this?
Issue Analytics
- State:
- Created 7 years ago
- Comments:22 (11 by maintainers)
Why not implement offline-caching?
This requires people to either include “the latest version of the JSON file” in their app during app-updates or leave a pre-written JSON file with a “Sorry please go online” view. Either way, I think this sticks to the original principles 😉
@jdrydn @jereze Today’s your lucky day guys. Try adding
{"offline": "true"}
tohead
:This is one of those undocumented features I didn’t have enough time to test so didn’t add to the documentation but actually works fine.
Please try it out and let us know 😃