UNPKG

forerunnerdb

Version:

A NoSQL document store database for browsers and Node.js.

1 lines 2.46 kB
!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){var d=a("../lib/Angular");b.exports=d},{"../lib/Angular":2}],2:[function(a,b,c){"use strict";var d=window.ForerunnerDB.shared,e={};d.addModule("Angular",e),e.extendCollection=function(a){var b=a.prototype.drop;a.prototype.ng=function(a,b,c){var d,e,f=this;if(!a||!b)throw this.logIdentifier()+" Cannot link to angular $scope if no scope or variable name is passed!";f._ngLinks=f._ngLinks||[],d={scope:a,varName:b,callback:function(){a[b]=f.find(),a.$apply()}},f._ngLinks.push(d),a.$on("$destroy",function(){if(f._ngLinks&&f._ngLinks.length)for(e=f._ngLinks.length-1;e>=0;e--)f._ngLinks[e].scope===a&&(f.off("change",d.callback),f._ngLinks.splice(e,1))}),f.on("change",d.callback)},a.prototype.drop=function(){return this._ngLinks&&delete this._ngLinks,b.apply(this,arguments)}},e.extendView=function(a){a.prototype.ng=function(a,b,c){var d=this.publicData();return d.ng(a,b,c),this}},e.extendDocument=function(a){var b=a.prototype.drop;a.prototype.ng=function(a,b,c){var d,e,f=this,g=!1;if(!a||!b)throw this.logIdentifier()+" Cannot link to angular $scope if no scope or variable name is passed!";f._ngLinks=f._ngLinks||[],d={scope:a,varName:b,callback:function(){a[b]=f.find(),a.$apply()}},f._ngLinks.push(d),a.$on("$destroy",function(){if(f._ngLinks&&f._ngLinks.length)for(e=f._ngLinks.length-1;e>=0;e--)f._ngLinks[e].scope===a&&(f.off("change",d.callback),f._ngLinks.splice(e,1))}),a.$watch(b,function(a){g=!0,console.log("Updating",a),f.update({},a),g=!1},!0),f.on("change",function(){g?console.log("Ignoring update as it is a watch update"):d.callback.apply(this,arguments)})},a.prototype.drop=function(){return this._ngLinks&&delete this._ngLinks,b.apply(this,arguments)}},e.extendOverview=function(a){a.prototype.ng=function(a,b,c){this._data.ng.apply(this._data,arguments),this._refresh()}};var f,g=["Collection","View","Overview","Document"],h=function(a,b){e["extend"+a]&&e["extend"+a](b)};for(f=0;f<g.length;f++)d.moduleFinished(g[f],h);d.finishModule("Angular"),b.exports=e},{}]},{},[1]);