PolymerElements / app-storage

Data-pipes and specialized services
61 stars 47 forks source link

Implement "cold boot" Firebase capability #10

Closed cdata closed 8 years ago

cdata commented 8 years ago

As a Polymer (plus Firebase) app user, when I start the app offline, I want data input to "just work", so that I don't have be online to use the app.

The Firebase client library has a "hidden" cold boot mode. Here is an example of how you use it:

// always online ref
var onlineRef = new Firebase("https://my.firebaseio.com");
// always offline ref
var offlineRef = new Firebase("https://my.firebaseio.com", "__offline__");
offlineRef.goOffline();

The second parameter (__offline__) allows the Firebase instance to be booted up and respond to local data changes caused by other such Firebase instances in the app. This is a very useful feature for implementing a "cold boot" mode for Firebase.

In order for this feature to work, the app's online / offline state needs to be monitored. When offline, the "offline" Firebase ref should be used. Then, when transitioning to the online state, the element should switch to using the "online" Firebase ref.

cdata commented 8 years ago

This feature is no longer being implemented due to "last-write-always-wins" behavior in Firebase.