UNPKG

cc.fovea.cordova.purchase

Version:

Cordova Purchase plugin for iOS, Android, Windows (AppStore, Play, UWP)

51 lines (43 loc) 1.08 kB
(function(){ /// /// ## *store.error.callbacks* array /// /// Array of user registered error callbacks. store.error.callbacks = []; /// /// ### *store.error.callbacks.trigger(error)* /// /// Execute all error callbacks with the given `error` argument. store.error.callbacks.trigger = function(error) { for (var i = 0; i < this.length; ++i) { try { this[i].call(store, error); } catch (err) { store.utils.logError("error", err); deferThrow(err); } } }; /// /// ### *store.error.callbacks.reset()* /// /// Remove all error callbacks. store.error.callbacks.reset = function() { while (this.length > 0) this.shift(); }; store.error.callbacks.unregister = function(cb) { var newArray = this.filter(function(o) { return o !== cb; }); if (newArray.length < this.length) { this.reset(); for (var i = 0; i < newArray.length; ++i) this.push(newArray[i]); } }; function deferThrow(err) { setTimeout(function() { throw err; }, 1); } })();