dist/index.js
function onValue(dbRef, snapCallback, processedCallback, cancelCallbackOrContext, context) {
		var storageKey = getStorageKeyFromDbRef(dbRef, 'value');

		return _reactNative.AsyncStorage.getItem(storageKey).then(function (value) {
			// Called processedCallback with cached value.
			if (value !== null) {
				var cachedVal = JSON.parse(value);
				callWithContext(processedCallback, cachedVal, cancelCallbackOrContext, context);
			}
		}).then(function () {
			var callbackPeak = function callbackPeak(snap) {
				var processed = snapCallback.bind(this)(snap);
				snapPeak[storageKey] = JSON.stringify(processed);
				processedCallback.bind(this)(processed);
			};
			dbRef.on('value', callbackPeak, cancelCallbackOrContext, context);
		});
	}
function onValue(dbRef, snapCallback, processedCallback, cancelCallbackOrContext, context) {
		var storageKey = getStorageKeyFromDbRef(dbRef, 'value');

		return _reactNative.AsyncStorage.getItem(storageKey).then(function (value) {
			// Called processedCallback with cached value.
			if (value !== null) {
				var cachedVal = JSON.parse(value);
				callWithContext(processedCallback, cachedVal, cancelCallbackOrContext, context);
			}
		}).then(function () {
			var callbackPeak = function callbackPeak(snap) {
				var processed = snapCallback.bind(this)(snap);
				snapPeak[storageKey] = JSON.stringify(processed);
				processedCallback.bind(this)(processed);
			};
			dbRef.on('value', callbackPeak, cancelCallbackOrContext, context);
		});
	}
function onValue ( dbRef , snapCallback , processedCallback , cancelCallbackOrContext , context ) { var storageKey = getStorageKeyFromDbRef ( dbRef , 'value' ) ; return _reactNative . AsyncStorage . getItem ( storageKey ) . then ( function ( value ) { // Called processedCallback with cached value. if ( value !== null ) { var cachedVal = JSON . parse ( value ) ; callWithContext ( processedCallback , cachedVal , cancelCallbackOrContext , context ) ; } } ) . then ( function ( ) { var callbackPeak = function callbackPeak ( snap ) { var processed = snapCallback . bind ( this ) ( snap ) ; snapPeak [ storageKey ] = JSON . stringify ( processed ) ; processedCallback . bind ( this ) ( processed ) ; } ; dbRef . on ( 'value' , callbackPeak , cancelCallbackOrContext , context ) ; } ) ; }
Create an 'value' on listener that will first return a cached version of the endpoint.
@param {firebase.database.Reference} dbRef Firebase database reference to listen at.
@param {Function} snapCallback Callback called when a new snapshot is available. Should return a JSON.stringify-able object that will be cached.
@param {Function} processedCallback Callback called with data returned by snapCallback, or cached data if available.
@param {Function|Object} cancelCallbackOrContext An optional callback that will be notified if your event subscription is ever canceled because your client does not have permission to read this data (or it had permission but has now lost it). This callback will be passed an Error object indicating why the failure occurred.
@param {Object} context If provided, this object will be used as this when calling your callback(s).
@returns {Promise} Resolves when the cache has been read and listener attached to DB ref.
Create an value on listener that will first return a cached version of the endpoint .