Progressive web apps, offline persistence, and multiple browser tabs

153 views
Skip to first unread message

Chetstone

unread,
Jun 9, 2016, 1:51:51 PM6/9/16
to Firebase Google Group
Question for William Bleigh..

I watched your Progressive Web Apps presentation with great interest, thank you! I was wondering whether the polymer app-storage offline persistence can correctly deal with the ambiguity present when the app is open in more than one browser tab? Specifically, I am asking about the scenario described here. The only mechanism I can think of is if somehow app-cache manifest has a way of preventing the app from opening in more than one tab/window and referring all requests to the already-open tab.

Thanks.
Chester

Michael Bleigh

unread,
Jun 13, 2016, 11:12:10 PM6/13/16
to fireba...@googlegroups.com
Hey Chester,

Multi-tab is definitely a non-trivial thing to consider and isn't something PolymerFire will handle for you out of the box. If you want to straight-up prevent multiple tabs it's definitely doable -- localStorage is a synchronous API so you could just write a key in localStorage when a tab opens and clear it in an "onbeforeunload" (there's probably some edge cases for crashes etc. you'd need to handle).

Depending on your app's logic you could also store the counter increments locally in some kind of time-series to do some local conflict resolution and keep a single canonical count that gets persisted.

Again, this is definitely a non-trivial thing to handle and I'd be interested to hear how you end up tackling it. Sorry for the delayed response!

-Michael

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/e34ff7ca-732b-4ced-8dea-895108183975%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Chester Wood

unread,
Jun 14, 2016, 4:23:42 PM6/14/16
to fireba...@googlegroups.com
Michael,

Thanks a lot for the informative reply. 
Interesting ideas, food for thought. But Hmm.. Edge cases, hazardous. Maybe it would suffice to, upon detecting a possible conflict, offer the user a chance to "certify" that there are no other tabs open. And the time series idea is a possibility too... I already store locally a limited history of the most recent increments, I'd have to think more about how that would work.

I've ducked the issue so far by building the app in React-Native for iOS and relegating the web app to a simple demo. But as I'm closing in on my first release to the app store, I'm thinking about other platforms and wondering whether to tackle this issue and build a full-fledged mobile web app. 

Good to know that Polymer won't solve the problem by itself, thus no need to scrap my own local persistence to swap in something else. But certainly there are several other "Progressive" techniques you mentioned in your talk that will be very helpful.

Thanks again,

Chester
Reply all
Reply to author
Forward
0 new messages