marsdb-angular
Advanced tools
Comparing version 0.0.6 to 0.0.7
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
'use strict'; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; | ||
@@ -13,8 +15,2 @@ | ||
var _AngularCursorObservable = require('./AngularCursorObservable'); | ||
var _AngularCursorObservable2 = _interopRequireDefault(_AngularCursorObservable); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -38,3 +34,3 @@ | ||
var AngularCollectionDelegate = (function (_defaultDelegate2) { | ||
var AngularCollectionDelegate = function (_defaultDelegate2) { | ||
_inherits(AngularCollectionDelegate, _defaultDelegate2); | ||
@@ -90,3 +86,3 @@ | ||
return new _AngularCursorObservable2.default(this.$q, this.db, query, options); | ||
return _get(Object.getPrototypeOf(AngularCollectionDelegate.prototype), 'find', this).call(this, query, _extends({}, options, { _$q: this.$q })); | ||
} | ||
@@ -96,10 +92,10 @@ }]); | ||
return AngularCollectionDelegate; | ||
})(_defaultDelegate); | ||
}(_defaultDelegate); | ||
return AngularCollectionDelegate; | ||
} | ||
},{"./AngularCursorObservable":2,"marsdb":undefined}],2:[function(require,module,exports){ | ||
},{"marsdb":undefined}],2:[function(require,module,exports){ | ||
'use strict'; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
@@ -111,2 +107,3 @@ var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; | ||
}); | ||
exports.createCursor = createCursor; | ||
@@ -119,89 +116,87 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var CursorObservable = typeof window !== 'undefined' && window.Mars ? window.Mars.CursorObservable : require('marsdb').CursorObservable; | ||
var Collection = typeof window !== 'undefined' && window.Mars ? window.Mars.Collection : require('marsdb').Collection; | ||
var AngularCursorObservable = exports.AngularCursorObservable = (function (_CursorObservable) { | ||
_inherits(AngularCursorObservable, _CursorObservable); | ||
/** | ||
* Function that creates a cursor class based on current default | ||
* cursor class in a collection | ||
* @return {Cursor} | ||
*/ | ||
function createCursor() { | ||
var _defaultCursor = Collection.defaultCursor(); | ||
function AngularCursorObservable($q) { | ||
var _Object$getPrototypeO; | ||
var AngularCursorObservable = function (_defaultCursor2) { | ||
_inherits(AngularCursorObservable, _defaultCursor2); | ||
_classCallCheck(this, AngularCursorObservable); | ||
function AngularCursorObservable() { | ||
_classCallCheck(this, AngularCursorObservable); | ||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
return _possibleConstructorReturn(this, Object.getPrototypeOf(AngularCursorObservable).apply(this, arguments)); | ||
} | ||
var _this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(AngularCursorObservable)).call.apply(_Object$getPrototypeO, [this].concat(args))); | ||
_createClass(AngularCursorObservable, [{ | ||
key: 'destroy', | ||
_this.$q = $q; | ||
return _this; | ||
} | ||
/** | ||
* Stop observing given cursor, if passed and | ||
* observing. | ||
* It might be useful when you need to replace | ||
* previously created request with another one | ||
* (with different query, for example). | ||
* @param {CursorObservable} cursor | ||
*/ | ||
value: function destroy(cursor) { | ||
console.warn('DEPRECATED: `destroy` of cursor is deprecated! use `stopObservers` instead'); | ||
return this.stopObservers(); | ||
} | ||
/** | ||
* Stop observing given cursor, if passed and | ||
* observing. | ||
* It might be useful when you need to replace | ||
* previously created request with another one | ||
* (with different query, for example). | ||
* | ||
* @param {CursorObservable} cursor | ||
*/ | ||
/** | ||
* Original `observe` with one additional argument. | ||
* Second argument, if passed, a $scope for tracking | ||
* $destroy event and stopping observing when event | ||
* emited. | ||
* @param {Function} fn | ||
* @param {Scope} $scope | ||
* @return {Stooper} | ||
*/ | ||
_createClass(AngularCursorObservable, [{ | ||
key: 'destroy', | ||
value: function destroy(cursor) { | ||
console.warn('DEPRECATED: `destroy` of cursor is deprecated! use `stopObservers` instead'); | ||
return this.stopObservers(); | ||
} | ||
}, { | ||
key: 'observe', | ||
value: function observe(fn, $scope) { | ||
var stopper = _get(Object.getPrototypeOf(AngularCursorObservable.prototype), 'observe', this).call(this, fn); | ||
if ($scope) { | ||
$scope.$on('$destroy', function () { | ||
stopper.stop(); | ||
}); | ||
} | ||
return stopper; | ||
} | ||
}, { | ||
key: '_doUpdate', | ||
value: function _doUpdate() { | ||
var _get2; | ||
/** | ||
* Original `observe` with one additional argument. | ||
* Second argument, if passed, a $scope for tracking | ||
* $destroy event and stopping observing when event | ||
* emited. | ||
* | ||
* @param {Function} fn | ||
* @param {Scope} $scope | ||
* @return {Stooper} | ||
*/ | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
}, { | ||
key: 'observe', | ||
value: function observe(fn, $scope) { | ||
var stopper = _get(Object.getPrototypeOf(AngularCursorObservable.prototype), 'observe', this).call(this, fn); | ||
if ($scope) { | ||
$scope.$on('$destroy', function () { | ||
stopper.stop(); | ||
}); | ||
return this.options._$q.resolve((_get2 = _get(Object.getPrototypeOf(AngularCursorObservable.prototype), '_doUpdate', this)).call.apply(_get2, [this].concat(args))); | ||
} | ||
return stopper; | ||
} | ||
}, { | ||
key: '_doUpdate', | ||
value: function _doUpdate() { | ||
var _get2; | ||
}, { | ||
key: 'then', | ||
value: function then() { | ||
var _get3; | ||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
return this.$q.resolve((_get2 = _get(Object.getPrototypeOf(AngularCursorObservable.prototype), '_doUpdate', this)).call.apply(_get2, [this].concat(args))); | ||
} | ||
}, { | ||
key: 'then', | ||
value: function then() { | ||
var _get3; | ||
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { | ||
args[_key3] = arguments[_key3]; | ||
return this.options._$q.resolve((_get3 = _get(Object.getPrototypeOf(AngularCursorObservable.prototype), 'then', this)).call.apply(_get3, [this].concat(args))); | ||
} | ||
}]); | ||
return this.$q.resolve((_get3 = _get(Object.getPrototypeOf(AngularCursorObservable.prototype), 'then', this)).call.apply(_get3, [this].concat(args))); | ||
} | ||
}]); | ||
return AngularCursorObservable; | ||
}(_defaultCursor); | ||
return AngularCursorObservable; | ||
})(CursorObservable); | ||
exports.default = AngularCursorObservable; | ||
} | ||
},{"marsdb":undefined}],3:[function(require,module,exports){ | ||
@@ -212,2 +207,4 @@ 'use strict'; | ||
var _AngularCursorObservable = require('./AngularCursorObservable'); | ||
var angular = typeof window !== 'undefined' && window.angular ? window.angular : require('angular'); | ||
@@ -218,4 +215,4 @@ var Collection = typeof window !== 'undefined' && window.Mars ? window.Mars.Collection : require('marsdb').Collection; | ||
angular.module('MarsDB', []).provider('$collection', function () { | ||
var _angularCollectionDelegate = (0, _AngularCollectionDelegate.createCollectionDelegate)(); | ||
Collection.defaultDelegate(_angularCollectionDelegate); | ||
Collection.defaultDelegate((0, _AngularCollectionDelegate.createCollectionDelegate)()); | ||
Collection.defaultCursor((0, _AngularCursorObservable.createCursor)()); | ||
@@ -260,5 +257,5 @@ this.defaultDelegate = function (delegate) { | ||
module.export = 'MarsDB'; | ||
},{"./AngularCollectionDelegate":1,"angular":undefined,"marsdb":undefined}],4:[function(require,module,exports){ | ||
},{"./AngularCollectionDelegate":1,"./AngularCursorObservable":2,"angular":undefined,"marsdb":undefined}],4:[function(require,module,exports){ | ||
module.exports = require('./dist/index'); | ||
},{"./dist/index":3}]},{},[4]); |
@@ -1,1 +0,1 @@ | ||
!function e(t,r,n){function o(u,i){if(!r[u]){if(!t[u]){var l="function"==typeof require&&require;if(!i&&l)return l(u,!0);if(a)return a(u,!0);var s=new Error("Cannot find module '"+u+"'");throw s.code="MODULE_NOT_FOUND",s}var c=r[u]={exports:{}};t[u][0].call(c.exports,function(e){var r=t[u][1][e];return o(r?r:e)},c,c.exports,e,t,r,n)}return r[u].exports}for(var a="function"==typeof require&&require,u=0;u<n.length;u++)o(n[u]);return o}({1:[function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function i(){var e=p.defaultDelegate(),t=function(e){function t(e,r){o(this,t);var n=a(this,Object.getPrototypeOf(t).call(this,e,r));return n.db=e,n.$q=r._$q,n}return u(t,e),l(t,[{key:"insert",value:function(){for(var e,r=arguments.length,n=Array(r),o=0;r>o;o++)n[o]=arguments[o];return this.$q.resolve((e=s(Object.getPrototypeOf(t.prototype),"insert",this)).call.apply(e,[this].concat(n)))}},{key:"remove",value:function(){for(var e,r=arguments.length,n=Array(r),o=0;r>o;o++)n[o]=arguments[o];return this.$q.resolve((e=s(Object.getPrototypeOf(t.prototype),"remove",this)).call.apply(e,[this].concat(n)))}},{key:"update",value:function(){for(var e,r=arguments.length,n=Array(r),o=0;r>o;o++)n[o]=arguments[o];return this.$q.resolve((e=s(Object.getPrototypeOf(t.prototype),"update",this)).call.apply(e,[this].concat(n)))}},{key:"find",value:function(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return new f["default"](this.$q,this.db,e,t)}}]),t}(e);return t}var l=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),s=function d(e,t,r){null===e&&(e=Function.prototype);var n=Object.getOwnPropertyDescriptor(e,t);if(void 0===n){var o=Object.getPrototypeOf(e);return null===o?void 0:d(o,t,r)}if("value"in n)return n.value;var a=n.get;if(void 0!==a)return a.call(r)};Object.defineProperty(r,"__esModule",{value:!0}),r.createCollectionDelegate=i;var c=e("./AngularCursorObservable"),f=n(c),p="undefined"!=typeof window&&window.Mars?window.Mars.Collection:e("marsdb").Collection},{"./AngularCursorObservable":2,marsdb:void 0}],2:[function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var u=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=function c(e,t,r){null===e&&(e=Function.prototype);var n=Object.getOwnPropertyDescriptor(e,t);if(void 0===n){var o=Object.getPrototypeOf(e);return null===o?void 0:c(o,t,r)}if("value"in n)return n.value;var a=n.get;if(void 0!==a)return a.call(r)};Object.defineProperty(r,"__esModule",{value:!0});var l="undefined"!=typeof window&&window.Mars?window.Mars.CursorObservable:e("marsdb").CursorObservable,s=r.AngularCursorObservable=function(e){function t(e){var r;n(this,t);for(var a=arguments.length,u=Array(a>1?a-1:0),i=1;a>i;i++)u[i-1]=arguments[i];var l=o(this,(r=Object.getPrototypeOf(t)).call.apply(r,[this].concat(u)));return l.$q=e,l}return a(t,e),u(t,[{key:"destroy",value:function(e){return console.warn("DEPRECATED: `destroy` of cursor is deprecated! use `stopObservers` instead"),this.stopObservers()}},{key:"observe",value:function(e,r){var n=i(Object.getPrototypeOf(t.prototype),"observe",this).call(this,e);return r&&r.$on("$destroy",function(){n.stop()}),n}},{key:"_doUpdate",value:function(){for(var e,r=arguments.length,n=Array(r),o=0;r>o;o++)n[o]=arguments[o];return this.$q.resolve((e=i(Object.getPrototypeOf(t.prototype),"_doUpdate",this)).call.apply(e,[this].concat(n)))}},{key:"then",value:function(){for(var e,r=arguments.length,n=Array(r),o=0;r>o;o++)n[o]=arguments[o];return this.$q.resolve((e=i(Object.getPrototypeOf(t.prototype),"then",this)).call.apply(e,[this].concat(n)))}}]),t}(l);r["default"]=s},{marsdb:void 0}],3:[function(e,t,r){"use strict";var n=e("./AngularCollectionDelegate"),o="undefined"!=typeof window&&window.angular?window.angular:e("angular"),a="undefined"!=typeof window&&window.Mars?window.Mars.Collection:e("marsdb").Collection;o.module("MarsDB",[]).provider("$collection",function(){var e=(0,n.createCollectionDelegate)();a.defaultDelegate(e),this.defaultDelegate=function(e){return a.defaultDelegate(e),this},this.defaultStorageManager=function(e){return a.defaultStorageManager(e),this},this.defaultIdGenerator=function(e){return a.defaultIdGenerator(e),this};var t={};this.$get=["$q",function(e){return function(r){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if(n._$q=e,t[r]&&!n.noCache)return t[r];var o=new a(r,n);return n.noCache||(t[r]=o),o}}]}),t["export"]="MarsDB"},{"./AngularCollectionDelegate":1,angular:void 0,marsdb:void 0}],4:[function(e,t,r){t.exports=e("./dist/index")},{"./dist/index":3}]},{},[4]); | ||
!function e(t,r,n){function o(i,u){if(!r[i]){if(!t[i]){var l="function"==typeof require&&require;if(!u&&l)return l(i,!0);if(a)return a(i,!0);var c=new Error("Cannot find module '"+i+"'");throw c.code="MODULE_NOT_FOUND",c}var s=r[i]={exports:{}};t[i][0].call(s.exports,function(e){var r=t[i][1][e];return o(r?r:e)},s,s.exports,e,t,r,n)}return r[i].exports}for(var a="function"==typeof require&&require,i=0;i<n.length;i++)o(n[i]);return o}({1:[function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function i(){var e=s.defaultDelegate(),t=function(e){function t(e,r){n(this,t);var a=o(this,Object.getPrototypeOf(t).call(this,e,r));return a.db=e,a.$q=r._$q,a}return a(t,e),l(t,[{key:"insert",value:function(){for(var e,r=arguments.length,n=Array(r),o=0;r>o;o++)n[o]=arguments[o];return this.$q.resolve((e=c(Object.getPrototypeOf(t.prototype),"insert",this)).call.apply(e,[this].concat(n)))}},{key:"remove",value:function(){for(var e,r=arguments.length,n=Array(r),o=0;r>o;o++)n[o]=arguments[o];return this.$q.resolve((e=c(Object.getPrototypeOf(t.prototype),"remove",this)).call.apply(e,[this].concat(n)))}},{key:"update",value:function(){for(var e,r=arguments.length,n=Array(r),o=0;r>o;o++)n[o]=arguments[o];return this.$q.resolve((e=c(Object.getPrototypeOf(t.prototype),"update",this)).call.apply(e,[this].concat(n)))}},{key:"find",value:function(e){var r=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return c(Object.getPrototypeOf(t.prototype),"find",this).call(this,e,u({},r,{_$q:this.$q}))}}]),t}(e);return t}var u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},l=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),c=function f(e,t,r){null===e&&(e=Function.prototype);var n=Object.getOwnPropertyDescriptor(e,t);if(void 0===n){var o=Object.getPrototypeOf(e);return null===o?void 0:f(o,t,r)}if("value"in n)return n.value;var a=n.get;if(void 0!==a)return a.call(r)};Object.defineProperty(r,"__esModule",{value:!0}),r.createCollectionDelegate=i;var s="undefined"!=typeof window&&window.Mars?window.Mars.Collection:e("marsdb").Collection},{marsdb:void 0}],2:[function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function i(){var e=c.defaultCursor(),t=function(e){function t(){return n(this,t),o(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),u(t,[{key:"destroy",value:function(e){return console.warn("DEPRECATED: `destroy` of cursor is deprecated! use `stopObservers` instead"),this.stopObservers()}},{key:"observe",value:function(e,r){var n=l(Object.getPrototypeOf(t.prototype),"observe",this).call(this,e);return r&&r.$on("$destroy",function(){n.stop()}),n}},{key:"_doUpdate",value:function(){for(var e,r=arguments.length,n=Array(r),o=0;r>o;o++)n[o]=arguments[o];return this.options._$q.resolve((e=l(Object.getPrototypeOf(t.prototype),"_doUpdate",this)).call.apply(e,[this].concat(n)))}},{key:"then",value:function(){for(var e,r=arguments.length,n=Array(r),o=0;r>o;o++)n[o]=arguments[o];return this.options._$q.resolve((e=l(Object.getPrototypeOf(t.prototype),"then",this)).call.apply(e,[this].concat(n)))}}]),t}(e);return t}var u=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),l=function s(e,t,r){null===e&&(e=Function.prototype);var n=Object.getOwnPropertyDescriptor(e,t);if(void 0===n){var o=Object.getPrototypeOf(e);return null===o?void 0:s(o,t,r)}if("value"in n)return n.value;var a=n.get;if(void 0!==a)return a.call(r)};Object.defineProperty(r,"__esModule",{value:!0}),r.createCursor=i;var c="undefined"!=typeof window&&window.Mars?window.Mars.Collection:e("marsdb").Collection},{marsdb:void 0}],3:[function(e,t,r){"use strict";var n=e("./AngularCollectionDelegate"),o=e("./AngularCursorObservable"),a="undefined"!=typeof window&&window.angular?window.angular:e("angular"),i="undefined"!=typeof window&&window.Mars?window.Mars.Collection:e("marsdb").Collection;a.module("MarsDB",[]).provider("$collection",function(){i.defaultDelegate((0,n.createCollectionDelegate)()),i.defaultCursor((0,o.createCursor)()),this.defaultDelegate=function(e){return i.defaultDelegate(e),this},this.defaultStorageManager=function(e){return i.defaultStorageManager(e),this},this.defaultIdGenerator=function(e){return i.defaultIdGenerator(e),this};var e={};this.$get=["$q",function(t){return function(r){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if(n._$q=t,e[r]&&!n.noCache)return e[r];var o=new i(r,n);return n.noCache||(e[r]=o),o}}]}),t["export"]="MarsDB"},{"./AngularCollectionDelegate":1,"./AngularCursorObservable":2,angular:void 0,marsdb:void 0}],4:[function(e,t,r){t.exports=e("./dist/index")},{"./dist/index":3}]},{},[4]); |
'use strict'; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; | ||
@@ -12,8 +14,2 @@ | ||
var _AngularCursorObservable = require('./AngularCursorObservable'); | ||
var _AngularCursorObservable2 = _interopRequireDefault(_AngularCursorObservable); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -37,3 +33,3 @@ | ||
var AngularCollectionDelegate = (function (_defaultDelegate2) { | ||
var AngularCollectionDelegate = function (_defaultDelegate2) { | ||
_inherits(AngularCollectionDelegate, _defaultDelegate2); | ||
@@ -89,3 +85,3 @@ | ||
return new _AngularCursorObservable2.default(this.$q, this.db, query, options); | ||
return _get(Object.getPrototypeOf(AngularCollectionDelegate.prototype), 'find', this).call(this, query, _extends({}, options, { _$q: this.$q })); | ||
} | ||
@@ -95,5 +91,5 @@ }]); | ||
return AngularCollectionDelegate; | ||
})(_defaultDelegate); | ||
}(_defaultDelegate); | ||
return AngularCollectionDelegate; | ||
} |
'use strict'; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
@@ -10,2 +10,3 @@ var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; | ||
}); | ||
exports.createCursor = createCursor; | ||
@@ -18,88 +19,86 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var CursorObservable = typeof window !== 'undefined' && window.Mars ? window.Mars.CursorObservable : require('marsdb').CursorObservable; | ||
var Collection = typeof window !== 'undefined' && window.Mars ? window.Mars.Collection : require('marsdb').Collection; | ||
var AngularCursorObservable = exports.AngularCursorObservable = (function (_CursorObservable) { | ||
_inherits(AngularCursorObservable, _CursorObservable); | ||
/** | ||
* Function that creates a cursor class based on current default | ||
* cursor class in a collection | ||
* @return {Cursor} | ||
*/ | ||
function createCursor() { | ||
var _defaultCursor = Collection.defaultCursor(); | ||
function AngularCursorObservable($q) { | ||
var _Object$getPrototypeO; | ||
var AngularCursorObservable = function (_defaultCursor2) { | ||
_inherits(AngularCursorObservable, _defaultCursor2); | ||
_classCallCheck(this, AngularCursorObservable); | ||
function AngularCursorObservable() { | ||
_classCallCheck(this, AngularCursorObservable); | ||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
return _possibleConstructorReturn(this, Object.getPrototypeOf(AngularCursorObservable).apply(this, arguments)); | ||
} | ||
var _this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(AngularCursorObservable)).call.apply(_Object$getPrototypeO, [this].concat(args))); | ||
_createClass(AngularCursorObservable, [{ | ||
key: 'destroy', | ||
_this.$q = $q; | ||
return _this; | ||
} | ||
/** | ||
* Stop observing given cursor, if passed and | ||
* observing. | ||
* It might be useful when you need to replace | ||
* previously created request with another one | ||
* (with different query, for example). | ||
* @param {CursorObservable} cursor | ||
*/ | ||
value: function destroy(cursor) { | ||
console.warn('DEPRECATED: `destroy` of cursor is deprecated! use `stopObservers` instead'); | ||
return this.stopObservers(); | ||
} | ||
/** | ||
* Stop observing given cursor, if passed and | ||
* observing. | ||
* It might be useful when you need to replace | ||
* previously created request with another one | ||
* (with different query, for example). | ||
* | ||
* @param {CursorObservable} cursor | ||
*/ | ||
/** | ||
* Original `observe` with one additional argument. | ||
* Second argument, if passed, a $scope for tracking | ||
* $destroy event and stopping observing when event | ||
* emited. | ||
* @param {Function} fn | ||
* @param {Scope} $scope | ||
* @return {Stooper} | ||
*/ | ||
_createClass(AngularCursorObservable, [{ | ||
key: 'destroy', | ||
value: function destroy(cursor) { | ||
console.warn('DEPRECATED: `destroy` of cursor is deprecated! use `stopObservers` instead'); | ||
return this.stopObservers(); | ||
} | ||
}, { | ||
key: 'observe', | ||
value: function observe(fn, $scope) { | ||
var stopper = _get(Object.getPrototypeOf(AngularCursorObservable.prototype), 'observe', this).call(this, fn); | ||
if ($scope) { | ||
$scope.$on('$destroy', function () { | ||
stopper.stop(); | ||
}); | ||
} | ||
return stopper; | ||
} | ||
}, { | ||
key: '_doUpdate', | ||
value: function _doUpdate() { | ||
var _get2; | ||
/** | ||
* Original `observe` with one additional argument. | ||
* Second argument, if passed, a $scope for tracking | ||
* $destroy event and stopping observing when event | ||
* emited. | ||
* | ||
* @param {Function} fn | ||
* @param {Scope} $scope | ||
* @return {Stooper} | ||
*/ | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
}, { | ||
key: 'observe', | ||
value: function observe(fn, $scope) { | ||
var stopper = _get(Object.getPrototypeOf(AngularCursorObservable.prototype), 'observe', this).call(this, fn); | ||
if ($scope) { | ||
$scope.$on('$destroy', function () { | ||
stopper.stop(); | ||
}); | ||
return this.options._$q.resolve((_get2 = _get(Object.getPrototypeOf(AngularCursorObservable.prototype), '_doUpdate', this)).call.apply(_get2, [this].concat(args))); | ||
} | ||
return stopper; | ||
} | ||
}, { | ||
key: '_doUpdate', | ||
value: function _doUpdate() { | ||
var _get2; | ||
}, { | ||
key: 'then', | ||
value: function then() { | ||
var _get3; | ||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
return this.$q.resolve((_get2 = _get(Object.getPrototypeOf(AngularCursorObservable.prototype), '_doUpdate', this)).call.apply(_get2, [this].concat(args))); | ||
} | ||
}, { | ||
key: 'then', | ||
value: function then() { | ||
var _get3; | ||
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { | ||
args[_key3] = arguments[_key3]; | ||
return this.options._$q.resolve((_get3 = _get(Object.getPrototypeOf(AngularCursorObservable.prototype), 'then', this)).call.apply(_get3, [this].concat(args))); | ||
} | ||
}]); | ||
return this.$q.resolve((_get3 = _get(Object.getPrototypeOf(AngularCursorObservable.prototype), 'then', this)).call.apply(_get3, [this].concat(args))); | ||
} | ||
}]); | ||
return AngularCursorObservable; | ||
}(_defaultCursor); | ||
return AngularCursorObservable; | ||
})(CursorObservable); | ||
exports.default = AngularCursorObservable; | ||
} |
@@ -5,2 +5,4 @@ 'use strict'; | ||
var _AngularCursorObservable = require('./AngularCursorObservable'); | ||
var angular = typeof window !== 'undefined' && window.angular ? window.angular : require('angular'); | ||
@@ -11,4 +13,4 @@ var Collection = typeof window !== 'undefined' && window.Mars ? window.Mars.Collection : require('marsdb').Collection; | ||
angular.module('MarsDB', []).provider('$collection', function () { | ||
var _angularCollectionDelegate = (0, _AngularCollectionDelegate.createCollectionDelegate)(); | ||
Collection.defaultDelegate(_angularCollectionDelegate); | ||
Collection.defaultDelegate((0, _AngularCollectionDelegate.createCollectionDelegate)()); | ||
Collection.defaultCursor((0, _AngularCursorObservable.createCursor)()); | ||
@@ -15,0 +17,0 @@ this.defaultDelegate = function (delegate) { |
@@ -1,2 +0,1 @@ | ||
import AngularCursorObservable from './AngularCursorObservable'; | ||
const Collection = typeof window !== 'undefined' && window.Mars | ||
@@ -35,3 +34,3 @@ ? window.Mars.Collection : require('marsdb').Collection; | ||
find(query, options = {}) { | ||
return new AngularCursorObservable(this.$q, this.db, query, options); | ||
return super.find(query, {...options, _$q: this.$q}); | ||
} | ||
@@ -38,0 +37,0 @@ } |
@@ -1,54 +0,57 @@ | ||
const CursorObservable = typeof window !== 'undefined' && window.Mars | ||
? window.Mars.CursorObservable : require('marsdb').CursorObservable; | ||
const Collection = typeof window !== 'undefined' && window.Mars | ||
? window.Mars.Collection : require('marsdb').Collection; | ||
export class AngularCursorObservable extends CursorObservable { | ||
constructor($q, ...args) { | ||
super(...args); | ||
this.$q = $q; | ||
} | ||
/** | ||
* Function that creates a cursor class based on current default | ||
* cursor class in a collection | ||
* @return {Cursor} | ||
*/ | ||
export function createCursor() { | ||
const _defaultCursor = Collection.defaultCursor(); | ||
/** | ||
* Stop observing given cursor, if passed and | ||
* observing. | ||
* It might be useful when you need to replace | ||
* previously created request with another one | ||
* (with different query, for example). | ||
* | ||
* @param {CursorObservable} cursor | ||
*/ | ||
destroy(cursor) { | ||
console.warn('DEPRECATED: `destroy` of cursor is deprecated! use `stopObservers` instead'); | ||
return this.stopObservers(); | ||
} | ||
class AngularCursorObservable extends _defaultCursor { | ||
/** | ||
* Original `observe` with one additional argument. | ||
* Second argument, if passed, a $scope for tracking | ||
* $destroy event and stopping observing when event | ||
* emited. | ||
* | ||
* @param {Function} fn | ||
* @param {Scope} $scope | ||
* @return {Stooper} | ||
*/ | ||
observe(fn, $scope) { | ||
const stopper = super.observe(fn); | ||
if ($scope) { | ||
$scope.$on('$destroy', function() { | ||
stopper.stop(); | ||
}); | ||
/** | ||
* Stop observing given cursor, if passed and | ||
* observing. | ||
* It might be useful when you need to replace | ||
* previously created request with another one | ||
* (with different query, for example). | ||
* @param {CursorObservable} cursor | ||
*/ | ||
destroy(cursor) { | ||
console.warn('DEPRECATED: `destroy` of cursor is deprecated! use `stopObservers` instead'); | ||
return this.stopObservers(); | ||
} | ||
return stopper; | ||
} | ||
_doUpdate(...args) { | ||
return this.$q.resolve(super._doUpdate(...args)); | ||
/** | ||
* Original `observe` with one additional argument. | ||
* Second argument, if passed, a $scope for tracking | ||
* $destroy event and stopping observing when event | ||
* emited. | ||
* @param {Function} fn | ||
* @param {Scope} $scope | ||
* @return {Stooper} | ||
*/ | ||
observe(fn, $scope) { | ||
const stopper = super.observe(fn); | ||
if ($scope) { | ||
$scope.$on('$destroy', function() { | ||
stopper.stop(); | ||
}); | ||
} | ||
return stopper; | ||
} | ||
_doUpdate(...args) { | ||
return this.options._$q.resolve(super._doUpdate(...args)); | ||
} | ||
then(...args) { | ||
return this.options._$q.resolve(super.then(...args)); | ||
} | ||
} | ||
then(...args) { | ||
return this.$q.resolve(super.then(...args)); | ||
} | ||
return AngularCursorObservable; | ||
} | ||
export default AngularCursorObservable; |
import { createCollectionDelegate } from './AngularCollectionDelegate'; | ||
import { createCursor } from './AngularCursorObservable'; | ||
const angular = typeof window !== 'undefined' && window.angular | ||
@@ -11,4 +12,4 @@ ? window.angular : require('angular'); | ||
.provider('$collection', function() { | ||
const _angularCollectionDelegate = createCollectionDelegate(); | ||
Collection.defaultDelegate(_angularCollectionDelegate); | ||
Collection.defaultDelegate(createCollectionDelegate()); | ||
Collection.defaultCursor(createCursor()); | ||
@@ -15,0 +16,0 @@ this.defaultDelegate = function(delegate) { |
{ | ||
"name": "marsdb-angular", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"author": "Artem Artemev <art@studytime.me>", | ||
@@ -28,3 +28,3 @@ "contributors": [ | ||
"invariant": "^2.2.0", | ||
"marsdb": "^0.5.14" | ||
"marsdb": "^0.5.18" | ||
}, | ||
@@ -37,2 +37,3 @@ "devDependencies": { | ||
"babel-preset-es2015": "^6.3.13", | ||
"babel-preset-stage-0": "^6.3.13", | ||
"babel-register": "^6.3.13", | ||
@@ -39,0 +40,0 @@ "babelify": "^7.2.0", |
Sorry, the diff of this file is not supported yet
49277
37
735
33
Updatedmarsdb@^0.5.18