mobx-utils
Advanced tools
Comparing version 1.1.6 to 2.0.0-fix26
@@ -0,1 +1,5 @@ | ||
# 2.0.0 | ||
* Upgraded to MobX 3 | ||
# 1.1.6 | ||
@@ -2,0 +6,0 @@ |
@@ -15,3 +15,3 @@ "use strict"; | ||
this.model = model; | ||
this.localValues = mobx_1.asMap({}); | ||
this.localValues = mobx_1.observable.map({}); | ||
utils_1.invariant(mobx_1.isObservableObject(model), "createViewModel expects an observable object"); | ||
@@ -18,0 +18,0 @@ Object.keys(model).forEach(function (key) { |
@@ -59,5 +59,4 @@ export declare type PromiseState = "pending" | "fulfilled" | "rejected"; | ||
* @param {T} [initialValue=undefined] Optional predefined initial value | ||
* @param {any} [modifier=IDENTITY] MobX modifier, e.g. `asFlat`, to be applied to the resolved value | ||
* @returns {IPromiseBasedObservable<T>} | ||
*/ | ||
export declare function fromPromise<T>(promise: PromiseLike<T>, initialValue?: T, modifier?: (_: any) => any): IPromiseBasedObservable<T>; | ||
export declare function fromPromise<T>(promise: PromiseLike<T>, initialValue?: T): IPromiseBasedObservable<T>; |
@@ -8,11 +8,9 @@ "use strict"; | ||
var PromiseBasedObservable = (function () { | ||
function PromiseBasedObservable(promise, initialValue, modifier) { | ||
function PromiseBasedObservable(promise, initialValue) { | ||
if (initialValue === void 0) { initialValue = undefined; } | ||
if (modifier === void 0) { modifier = utils_1.IDENTITY; } | ||
var _this = this; | ||
this.promise = promise; | ||
this.modifier = modifier; | ||
this._state = mobx_1.observable("pending"); | ||
this._reason = mobx_1.observable(undefined); | ||
this._observable = mobx_1.observable(modifier(initialValue)); | ||
this._state = mobx_1.observable(exports.PENDING); // MWE: Hm... as any should not be needed... | ||
this._reason = mobx_1.observable.shallowBox(undefined); | ||
this._observable = mobx_1.observable.box(initialValue); | ||
promise.then(mobx_1.action("observableFromPromise-resolve", function (value) { | ||
@@ -101,10 +99,8 @@ _this._observable.set(value); | ||
* @param {T} [initialValue=undefined] Optional predefined initial value | ||
* @param {any} [modifier=IDENTITY] MobX modifier, e.g. `asFlat`, to be applied to the resolved value | ||
* @returns {IPromiseBasedObservable<T>} | ||
*/ | ||
function fromPromise(promise, initialValue, modifier) { | ||
function fromPromise(promise, initialValue) { | ||
if (initialValue === void 0) { initialValue = undefined; } | ||
if (modifier === void 0) { modifier = utils_1.IDENTITY; } | ||
return new PromiseBasedObservable(promise, initialValue, modifier); | ||
return new PromiseBasedObservable(promise, initialValue); | ||
} | ||
exports.fromPromise = fromPromise; |
@@ -28,3 +28,2 @@ /** | ||
* @param {T} [initialValue=undefined] optional initialValue that will be returned from `current` as long as the `sink` has not been called at least once | ||
* @param {any} [modifier=IDENTITY] optional mobx modifier that determines the the comparison and recursion strategy of the observable, for example `asFlat` or `asStructure` | ||
* @returns {{ | ||
@@ -31,0 +30,0 @@ * current(): T, |
@@ -31,3 +31,2 @@ "use strict"; | ||
* @param {T} [initialValue=undefined] optional initialValue that will be returned from `current` as long as the `sink` has not been called at least once | ||
* @param {any} [modifier=IDENTITY] optional mobx modifier that determines the the comparison and recursion strategy of the observable, for example `asFlat` or `asStructure` | ||
* @returns {{ | ||
@@ -34,0 +33,0 @@ * current(): T, |
@@ -16,3 +16,3 @@ export interface IStreamObserver<T> { | ||
* The provided expression is tracked by mobx as long as there are subscribers, automatically | ||
* emitting when new values become available. The expressions respect transactions. | ||
* emitting when new values become available. The expressions respect (trans)actions. | ||
* | ||
@@ -19,0 +19,0 @@ * @example |
@@ -18,3 +18,3 @@ "use strict"; | ||
* The provided expression is tracked by mobx as long as there are subscribers, automatically | ||
* emitting when new values become available. The expressions respect transactions. | ||
* emitting when new values become available. The expressions respect (trans)actions. | ||
* | ||
@@ -44,4 +44,10 @@ * @example | ||
unsubscribe: computedValue.observe(typeof observer === "function" | ||
? function (newValue) { return observer(newValue); } | ||
: function (newValue) { return observer.next(newValue); }) | ||
? function (_a) { | ||
var newValue = _a.newValue; | ||
return observer(newValue); | ||
} | ||
: function (_a) { | ||
var newValue = _a.newValue; | ||
return observer.next(newValue); | ||
}) | ||
}; | ||
@@ -58,3 +64,3 @@ } | ||
var _this = this; | ||
this.current = mobx_1.asReference(undefined); | ||
this.current = undefined; | ||
mobx_1.runInAction(function () { | ||
@@ -82,3 +88,3 @@ _this.current = initialValue; | ||
__decorate([ | ||
mobx_1.observable | ||
mobx_1.observable.ref | ||
], StreamListener.prototype, "current", void 0); | ||
@@ -85,0 +91,0 @@ __decorate([ |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("mobx")):"function"==typeof define&&define.amd?define(["mobx"],t):"object"==typeof exports?exports.mobxUtils=t(require("mobx")):e.mobxUtils=t(e.mobx)}(this,function(e){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function n(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}n(r(6)),n(r(9)),n(r(3)),n(r(11)),n(r(5)),n(r(7)),n(r(8)),n(r(12)),n(r(4)),n(r(10)),n(r(2))},function(t,r){t.exports=e},function(e,t){"use strict";function r(e,t){if(void 0===t&&(t="Illegal state"),!e)throw new Error("[mobx-utils] "+t)}function n(e){o.indexOf(e)===-1&&(o.push(e),console.error("[mobx-utils] Deprecated: "+e))}t.NOOP=function(){},t.IDENTITY=function(e){return e},t.invariant=r;var o=[];t.deprecated=n},function(e,t,r){"use strict";function n(e,t,r){void 0===t&&(t=i.NOOP),void 0===r&&(r=void 0);var n=!1,u=!1,s=r,c=function(){n&&(n=!1,t())},a=new o.Atom("ResourceBasedObservable",function(){i.invariant(!n&&!u),n=!0,e(function(e){o.extras.allowStateChanges(!0,function(){s=e,a.reportChanged()})})},c);return{current:function(){i.invariant(!u,"subscribingObservable has already been disposed");var e=a.reportObserved();return e||n||console.warn("Called `get` of an subscribingObservable outside a reaction. Current value will be returned but no new subscription has started"),s},dispose:function(){u=!0,c()},isAlive:function(){return n}}}var o=r(1),i=r(2);t.fromResource=n},function(e,t,r){"use strict";function n(e,t,r,n){if(void 0===r&&(r=0),void 0===n&&(n=0),!o.isObservableArray(e))throw new Error("Expected observable array as first argument");o.isAction(t)||(t=o.action("chunkProcessor",t));var i=function(){for(var r=function(){var r=0===n?e.length:Math.min(e.length,n),i=e.slice(0,r);o.runInAction(function(){return e.splice(0,r)}),t(i)};e.length>0;)r()};return r>0?o.autorunAsync(i,r):o.autorun(i)}var o=r(1);t.chunkProcessor=n},function(e,t,r){"use strict";function n(e){return new c(e)}var o=this&&this.__decorate||function(e,t,r,n){var o,i=arguments.length,u=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(u=(i<3?o(u):i>3?o(t,r,u):o(t,r))||u);return i>3&&u&&Object.defineProperty(t,r,u),u},i=r(1),u=r(2),s=["model","reset","submit","isDirty","isPropertyDirty"],c=function(){function e(e){var t=this;this.model=e,this.localValues=i.asMap({}),u.invariant(i.isObservableObject(e),"createViewModel expects an observable object"),Object.keys(e).forEach(function(e){u.invariant(s.indexOf(e)===-1,"The propertyname "+e+" is reserved and cannot be used with viewModels"),Object.defineProperty(t,e,{enumerable:!0,configurable:!0,get:function(){return t.isPropertyDirty(e)?t.localValues.get(e):t.model[e]},set:i.action(function(r){(t.isPropertyDirty(e)||r!==t.model[e])&&t.localValues.set(e,r)})})})}return Object.defineProperty(e.prototype,"isDirty",{get:function(){return this.localValues.size>0},enumerable:!0,configurable:!0}),e.prototype.isPropertyDirty=function(e){return this.localValues.has(e)},e.prototype.submit=function(){var e=this;this.localValues.keys().forEach(function(t){var r=e.localValues.get(t),n=e.model[t];i.isObservableArray(n)?n.replace(r):i.isObservableMap(n)?(n.clear(),n.merge(r)):e.model[t]=r}),this.localValues.clear()},e.prototype.reset=function(){this.localValues.clear()},e.prototype.resetProperty=function(e){this.localValues.delete(e)},e}();o([i.computed],c.prototype,"isDirty",null),o([i.action],c.prototype,"submit",null),o([i.action],c.prototype,"reset",null),o([i.action],c.prototype,"resetProperty",null),t.createViewModel=n},function(e,t,r){"use strict";function n(e,t,r){return void 0===t&&(t=void 0),void 0===r&&(r=i.IDENTITY),new u(e,t,r)}var o=r(1),i=r(2);t.PENDING="pending",t.FULFILLED="fulfilled",t.REJECTED="rejected";var u=function(){function e(e,t,r){void 0===t&&(t=void 0),void 0===r&&(r=i.IDENTITY);var n=this;this.promise=e,this.modifier=r,this._state=o.observable("pending"),this._reason=o.observable(void 0),this._observable=o.observable(r(t)),e.then(o.action("observableFromPromise-resolve",function(e){n._observable.set(e),n._state.set("fulfilled")}),o.action("observableFromPromise-reject",function(e){n._reason.set(e),n._observable.set(e),n._state.set("rejected")}))}return Object.defineProperty(e.prototype,"value",{get:function(){return this._observable.get()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return this._state.get()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"reason",{get:function(){return i.deprecated("In `fromPromise`: `.reason` is deprecated, use `.value` instead"),this._reason.get()},enumerable:!0,configurable:!0}),e.prototype.case=function(e){switch(this.state){case"pending":return e.pending&&e.pending();case"rejected":return e.rejected&&e.rejected(this.value);case"fulfilled":return e.fulfilled&&e.fulfilled(this.value)}},e}();t.fromPromise=n},function(e,t,r){"use strict";function n(e,t,r,n){void 0===r&&(r=1e4),void 0===n&&(n=function(){});var i=!1,u=setTimeout(function(){i||(s(),n())},r),s=o.when(e,function(){i=!0,clearTimeout(u),t()});return function(){clearTimeout(u),s()}}var o=r(1);t.whenWithTimeout=n},function(e,t,r){"use strict";function n(e,t){var r=o.extras.getAtom(e,t);if(!r)throw new Error("No computed provided, please provide an object created with `computed(() => expr)` or an object + property name");return r.observe(function(){})}var o=r(1);t.keepAlive=n},function(e,t,r){"use strict";function n(e,t,r){void 0===t&&(t=void 0),void 0===r&&(r=o.IDENTITY);var n=!1,u=i.observable(r(t)),s=function(){return n||(n=!0,e(function(e){i.extras.allowStateChanges(!0,function(){u.set(e)})})),u.get()},c=i.action("lazyObservable-reset",function(){return u.set(t),u.get()});return{current:s,refresh:function(){return n=!1,s()},reset:function(){return c()}}}var o=r(2),i=r(1);t.lazyObservable=n},function(e,t,r){"use strict";function n(e){return void 0===e&&(e=1e3),s[e]||("number"==typeof e?s[e]=o(e):s[e]=i()),s[e].current()}function o(e){var t;return u.fromResource(function(r){t=setInterval(function(){return r(Date.now())},e)},function(){clearInterval(t)},Date.now())}function i(){var e=u.fromResource(function(t){function r(){window.requestAnimationFrame(function(){t(Date.now()),e.isAlive()&&r()})}r()},function(){},Date.now());return e}var u=r(3),s={};t.now=n},function(e,t,r){"use strict";function n(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}function o(){return this}function i(e){var t=c.computed(e);return r={subscribe:function(e){return{unsubscribe:t.observe("function"==typeof e?function(t){return e(t)}:function(t){return e.next(t)})}}},r[n()]=o,r;var r}function u(e,t){return void 0===t&&(t=void 0),new a(e,t)}var s=this&&this.__decorate||function(e,t,r,n){var o,i=arguments.length,u=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(u=(i<3?o(u):i>3?o(t,r,u):o(t,r))||u);return i>3&&u&&Object.defineProperty(t,r,u),u},c=r(1);t.toStream=i;var a=function(){function e(e,t){var r=this;this.current=c.asReference(void 0),c.runInAction(function(){r.current=t,r.subscription=e.subscribe(r)})}return e.prototype.dispose=function(){this.subscription.unsubscribe()},e.prototype.next=function(e){this.current=e},e.prototype.complete=function(){this.subscription.unsubscribe(),this.dispose()},e.prototype.error=function(e){this.current=e,this.dispose()},e}();s([c.observable],a.prototype,"current",void 0),s([c.action],a.prototype,"next",null),s([c.action],a.prototype,"complete",null),s([c.action],a.prototype,"error",null),t.fromStream=u},function(e,t,r){"use strict";function n(e,t,r){if(void 0===r&&(r=0),!o.isObservableArray(e))throw new Error("Expected observable array as first argument");o.isAction(t)||(t=o.action("queueProcessor",t));var n=function(){var r=e.slice(0);o.runInAction(function(){return e.splice(0)}),r.forEach(t)};return r>0?o.autorunAsync(n,r):o.autorun(n)}var o=r(1);t.queueProcessor=n}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("mobx")):"function"==typeof define&&define.amd?define(["mobx"],t):"object"==typeof exports?exports.mobxUtils=t(require("mobx")):e.mobxUtils=t(e.mobx)}(this,function(e){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function n(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}n(r(6)),n(r(9)),n(r(3)),n(r(11)),n(r(5)),n(r(7)),n(r(8)),n(r(12)),n(r(4)),n(r(10)),n(r(2))},function(t,r){t.exports=e},function(e,t){"use strict";function r(e,t){if(void 0===t&&(t="Illegal state"),!e)throw new Error("[mobx-utils] "+t)}function n(e){o.indexOf(e)===-1&&(o.push(e),console.error("[mobx-utils] Deprecated: "+e))}t.NOOP=function(){},t.IDENTITY=function(e){return e},t.invariant=r;var o=[];t.deprecated=n},function(e,t,r){"use strict";function n(e,t,r){void 0===t&&(t=i.NOOP),void 0===r&&(r=void 0);var n=!1,u=!1,s=r,c=function(){n&&(n=!1,t())},a=new o.Atom("ResourceBasedObservable",function(){i.invariant(!n&&!u),n=!0,e(function(e){o.extras.allowStateChanges(!0,function(){s=e,a.reportChanged()})})},c);return{current:function(){i.invariant(!u,"subscribingObservable has already been disposed");var e=a.reportObserved();return e||n||console.warn("Called `get` of an subscribingObservable outside a reaction. Current value will be returned but no new subscription has started"),s},dispose:function(){u=!0,c()},isAlive:function(){return n}}}var o=r(1),i=r(2);t.fromResource=n},function(e,t,r){"use strict";function n(e,t,r,n){if(void 0===r&&(r=0),void 0===n&&(n=0),!o.isObservableArray(e))throw new Error("Expected observable array as first argument");o.isAction(t)||(t=o.action("chunkProcessor",t));var i=function(){for(var r=function(){var r=0===n?e.length:Math.min(e.length,n),i=e.slice(0,r);o.runInAction(function(){return e.splice(0,r)}),t(i)};e.length>0;)r()};return r>0?o.autorunAsync(i,r):o.autorun(i)}var o=r(1);t.chunkProcessor=n},function(e,t,r){"use strict";function n(e){return new c(e)}var o=this&&this.__decorate||function(e,t,r,n){var o,i=arguments.length,u=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(u=(i<3?o(u):i>3?o(t,r,u):o(t,r))||u);return i>3&&u&&Object.defineProperty(t,r,u),u},i=r(1),u=r(2),s=["model","reset","submit","isDirty","isPropertyDirty"],c=function(){function e(e){var t=this;this.model=e,this.localValues=i.observable.map({}),u.invariant(i.isObservableObject(e),"createViewModel expects an observable object"),Object.keys(e).forEach(function(e){u.invariant(s.indexOf(e)===-1,"The propertyname "+e+" is reserved and cannot be used with viewModels"),Object.defineProperty(t,e,{enumerable:!0,configurable:!0,get:function(){return t.isPropertyDirty(e)?t.localValues.get(e):t.model[e]},set:i.action(function(r){(t.isPropertyDirty(e)||r!==t.model[e])&&t.localValues.set(e,r)})})})}return Object.defineProperty(e.prototype,"isDirty",{get:function(){return this.localValues.size>0},enumerable:!0,configurable:!0}),e.prototype.isPropertyDirty=function(e){return this.localValues.has(e)},e.prototype.submit=function(){var e=this;this.localValues.keys().forEach(function(t){var r=e.localValues.get(t),n=e.model[t];i.isObservableArray(n)?n.replace(r):i.isObservableMap(n)?(n.clear(),n.merge(r)):e.model[t]=r}),this.localValues.clear()},e.prototype.reset=function(){this.localValues.clear()},e.prototype.resetProperty=function(e){this.localValues.delete(e)},e}();o([i.computed],c.prototype,"isDirty",null),o([i.action],c.prototype,"submit",null),o([i.action],c.prototype,"reset",null),o([i.action],c.prototype,"resetProperty",null),t.createViewModel=n},function(e,t,r){"use strict";function n(e,t){return void 0===t&&(t=void 0),new u(e,t)}var o=r(1),i=r(2);t.PENDING="pending",t.FULFILLED="fulfilled",t.REJECTED="rejected";var u=function(){function e(e,r){void 0===r&&(r=void 0);var n=this;this.promise=e,this._state=o.observable(t.PENDING),this._reason=o.observable.shallowBox(void 0),this._observable=o.observable.box(r),e.then(o.action("observableFromPromise-resolve",function(e){n._observable.set(e),n._state.set("fulfilled")}),o.action("observableFromPromise-reject",function(e){n._reason.set(e),n._observable.set(e),n._state.set("rejected")}))}return Object.defineProperty(e.prototype,"value",{get:function(){return this._observable.get()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return this._state.get()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"reason",{get:function(){return i.deprecated("In `fromPromise`: `.reason` is deprecated, use `.value` instead"),this._reason.get()},enumerable:!0,configurable:!0}),e.prototype.case=function(e){switch(this.state){case"pending":return e.pending&&e.pending();case"rejected":return e.rejected&&e.rejected(this.value);case"fulfilled":return e.fulfilled&&e.fulfilled(this.value)}},e}();t.fromPromise=n},function(e,t,r){"use strict";function n(e,t,r,n){void 0===r&&(r=1e4),void 0===n&&(n=function(){});var i=!1,u=setTimeout(function(){i||(s(),n())},r),s=o.when(e,function(){i=!0,clearTimeout(u),t()});return function(){clearTimeout(u),s()}}var o=r(1);t.whenWithTimeout=n},function(e,t,r){"use strict";function n(e,t){var r=o.extras.getAtom(e,t);if(!r)throw new Error("No computed provided, please provide an object created with `computed(() => expr)` or an object + property name");return r.observe(function(){})}var o=r(1);t.keepAlive=n},function(e,t,r){"use strict";function n(e,t,r){void 0===t&&(t=void 0),void 0===r&&(r=o.IDENTITY);var n=!1,u=i.observable(r(t)),s=function(){return n||(n=!0,e(function(e){i.extras.allowStateChanges(!0,function(){u.set(e)})})),u.get()},c=i.action("lazyObservable-reset",function(){return u.set(t),u.get()});return{current:s,refresh:function(){return n=!1,s()},reset:function(){return c()}}}var o=r(2),i=r(1);t.lazyObservable=n},function(e,t,r){"use strict";function n(e){return void 0===e&&(e=1e3),s[e]||("number"==typeof e?s[e]=o(e):s[e]=i()),s[e].current()}function o(e){var t;return u.fromResource(function(r){t=setInterval(function(){return r(Date.now())},e)},function(){clearInterval(t)},Date.now())}function i(){var e=u.fromResource(function(t){function r(){window.requestAnimationFrame(function(){t(Date.now()),e.isAlive()&&r()})}r()},function(){},Date.now());return e}var u=r(3),s={};t.now=n},function(e,t,r){"use strict";function n(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}function o(){return this}function i(e){var t=c.computed(e);return r={subscribe:function(e){return{unsubscribe:t.observe("function"==typeof e?function(t){var r=t.newValue;return e(r)}:function(t){var r=t.newValue;return e.next(r)})}}},r[n()]=o,r;var r}function u(e,t){return void 0===t&&(t=void 0),new a(e,t)}var s=this&&this.__decorate||function(e,t,r,n){var o,i=arguments.length,u=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(u=(i<3?o(u):i>3?o(t,r,u):o(t,r))||u);return i>3&&u&&Object.defineProperty(t,r,u),u},c=r(1);t.toStream=i;var a=function(){function e(e,t){var r=this;this.current=void 0,c.runInAction(function(){r.current=t,r.subscription=e.subscribe(r)})}return e.prototype.dispose=function(){this.subscription.unsubscribe()},e.prototype.next=function(e){this.current=e},e.prototype.complete=function(){this.subscription.unsubscribe(),this.dispose()},e.prototype.error=function(e){this.current=e,this.dispose()},e}();s([c.observable.ref],a.prototype,"current",void 0),s([c.action],a.prototype,"next",null),s([c.action],a.prototype,"complete",null),s([c.action],a.prototype,"error",null),t.fromStream=u},function(e,t,r){"use strict";function n(e,t,r){if(void 0===r&&(r=0),!o.isObservableArray(e))throw new Error("Expected observable array as first argument");o.isAction(t)||(t=o.action("queueProcessor",t));var n=function(){var r=e.slice(0);o.runInAction(function(){return e.splice(0)}),r.forEach(t)};return r>0?o.autorunAsync(n,r):o.autorun(n)}var o=r(1);t.queueProcessor=n}])}); |
{ | ||
"name": "mobx-utils", | ||
"version": "1.1.6", | ||
"version": "2.0.0-fix26", | ||
"description": "Utility functions and common patterns for MobX", | ||
@@ -39,3 +39,3 @@ "main": "lib/mobx-utils.js", | ||
"istanbul": "^0.3.21", | ||
"mobx": "^2.4.2", | ||
"mobx": "^3.0.0", | ||
"rxjs": "^5.0.2", | ||
@@ -45,3 +45,3 @@ "tape": "^4.2.2", | ||
"tslint-eslint-rules": "^2.1.0", | ||
"typescript": "^2.0.9", | ||
"typescript": "^2.1.4", | ||
"webpack": "^1.13.1" | ||
@@ -51,3 +51,3 @@ }, | ||
"peerDependencies": { | ||
"mobx": "^2.4.2" | ||
"mobx": "^3.0.0" | ||
}, | ||
@@ -63,2 +63,2 @@ "keywords": [ | ||
] | ||
} | ||
} |
@@ -27,3 +27,3 @@ # MobX-utils | ||
[lib/from-promise.js:103-107](https://github.com/mobxjs/mobx-utils/blob/a45d274dbac24c24b971c4b1acbed9302f965c56/lib/from-promise.js#L103-L107 "Source code on GitHub") | ||
[lib/from-promise.js:100-103](https://github.com/mobxjs/mobx-utils/blob/6cd6902d5a8dd745268eebace0a2d9477e286c16/lib/from-promise.js#L100-L103 "Source code on GitHub") | ||
@@ -43,3 +43,2 @@ `fromPromise` takes a Promise and returns an object with 3 observable properties that track | ||
- `initialValue` **T?** Optional predefined initial value (optional, default `undefined`) | ||
- `modifier` **any?** MobX modifier, e.g. `asFlat`, to be applied to the resolved value (optional, default `IDENTITY`) | ||
@@ -85,3 +84,3 @@ **Examples** | ||
[lib/lazy-observable.js:38-68](https://github.com/mobxjs/mobx-utils/blob/a45d274dbac24c24b971c4b1acbed9302f965c56/lib/lazy-observable.js#L38-L68 "Source code on GitHub") | ||
[lib/lazy-observable.js:37-67](https://github.com/mobxjs/mobx-utils/blob/6cd6902d5a8dd745268eebace0a2d9477e286c16/lib/lazy-observable.js#L37-L67 "Source code on GitHub") | ||
@@ -100,4 +99,4 @@ `lazyObservable` creates an observable around a `fetch` method that will not be invoked | ||
- `initialValue` **T?** optional initialValue that will be returned from `current` as long as the `sink` has not been called at least once (optional, default `undefined`) | ||
- `modifier` **any?** optional mobx modifier that determines the the comparison and recursion strategy of the observable, for example `asFlat` or `asStructure` (optional, default `IDENTITY`) | ||
- `fetch` | ||
- `modifier` | ||
@@ -124,3 +123,3 @@ **Examples** | ||
[lib/from-resource.js:68-104](https://github.com/mobxjs/mobx-utils/blob/a45d274dbac24c24b971c4b1acbed9302f965c56/lib/from-resource.js#L68-L104 "Source code on GitHub") | ||
[lib/from-resource.js:68-104](https://github.com/mobxjs/mobx-utils/blob/6cd6902d5a8dd745268eebace0a2d9477e286c16/lib/from-resource.js#L68-L104 "Source code on GitHub") | ||
@@ -190,7 +189,7 @@ `fromResource` creates an observable which current state can be inspected using `.current()`, | ||
[lib/observable-stream.js:37-51](https://github.com/mobxjs/mobx-utils/blob/a45d274dbac24c24b971c4b1acbed9302f965c56/lib/observable-stream.js#L37-L51 "Source code on GitHub") | ||
[lib/observable-stream.js:37-57](https://github.com/mobxjs/mobx-utils/blob/6cd6902d5a8dd745268eebace0a2d9477e286c16/lib/observable-stream.js#L37-L57 "Source code on GitHub") | ||
Converts an expression to an observable stream (a.k.a. TC 39 Observable / RxJS observable). | ||
The provided expression is tracked by mobx as long as there are subscribers, automatically | ||
emitting when new values become available. The expressions respect transactions. | ||
emitting when new values become available. The expressions respect (trans)actions. | ||
@@ -219,3 +218,3 @@ **Parameters** | ||
[lib/observable-stream.js:115-118](https://github.com/mobxjs/mobx-utils/blob/a45d274dbac24c24b971c4b1acbed9302f965c56/lib/observable-stream.js#L115-L118 "Source code on GitHub") | ||
[lib/observable-stream.js:121-124](https://github.com/mobxjs/mobx-utils/blob/6cd6902d5a8dd745268eebace0a2d9477e286c16/lib/observable-stream.js#L121-L124 "Source code on GitHub") | ||
@@ -247,3 +246,3 @@ Converts an subscribable, observable stream (TC 39 observable / RxJS stream) | ||
[lib/create-view-model.js:127-129](https://github.com/mobxjs/mobx-utils/blob/a45d274dbac24c24b971c4b1acbed9302f965c56/lib/create-view-model.js#L127-L129 "Source code on GitHub") | ||
[lib/create-view-model.js:127-129](https://github.com/mobxjs/mobx-utils/blob/6cd6902d5a8dd745268eebace0a2d9477e286c16/lib/create-view-model.js#L127-L129 "Source code on GitHub") | ||
@@ -299,3 +298,3 @@ `createViewModel` takes an object with observable properties (model) | ||
[lib/guarded-when.js:32-51](https://github.com/mobxjs/mobx-utils/blob/a45d274dbac24c24b971c4b1acbed9302f965c56/lib/guarded-when.js#L32-L51 "Source code on GitHub") | ||
[lib/guarded-when.js:32-51](https://github.com/mobxjs/mobx-utils/blob/6cd6902d5a8dd745268eebace0a2d9477e286c16/lib/guarded-when.js#L32-L51 "Source code on GitHub") | ||
@@ -336,3 +335,3 @@ Like normal `when`, except that this `when` will automatically dispose if the condition isn't met within a certain amount of time. | ||
[lib/keep-alive.js:31-36](https://github.com/mobxjs/mobx-utils/blob/a45d274dbac24c24b971c4b1acbed9302f965c56/lib/keep-alive.js#L31-L36 "Source code on GitHub") | ||
[lib/keep-alive.js:31-36](https://github.com/mobxjs/mobx-utils/blob/6cd6902d5a8dd745268eebace0a2d9477e286c16/lib/keep-alive.js#L31-L36 "Source code on GitHub") | ||
@@ -364,3 +363,3 @@ MobX normally suspends any computed value that is not in use by any reaction, | ||
[lib/keep-alive.js:31-36](https://github.com/mobxjs/mobx-utils/blob/a45d274dbac24c24b971c4b1acbed9302f965c56/lib/keep-alive.js#L31-L36 "Source code on GitHub") | ||
[lib/keep-alive.js:31-36](https://github.com/mobxjs/mobx-utils/blob/6cd6902d5a8dd745268eebace0a2d9477e286c16/lib/keep-alive.js#L31-L36 "Source code on GitHub") | ||
@@ -388,3 +387,3 @@ **Parameters** | ||
[lib/queue-processor.js:22-40](https://github.com/mobxjs/mobx-utils/blob/a45d274dbac24c24b971c4b1acbed9302f965c56/lib/queue-processor.js#L22-L40 "Source code on GitHub") | ||
[lib/queue-processor.js:22-40](https://github.com/mobxjs/mobx-utils/blob/6cd6902d5a8dd745268eebace0a2d9477e286c16/lib/queue-processor.js#L22-L40 "Source code on GitHub") | ||
@@ -417,3 +416,3 @@ `queueProcessor` takes an observable array, observes it and calls `processor` | ||
[lib/chunk-processor.js:27-52](https://github.com/mobxjs/mobx-utils/blob/a45d274dbac24c24b971c4b1acbed9302f965c56/lib/chunk-processor.js#L27-L52 "Source code on GitHub") | ||
[lib/chunk-processor.js:27-52](https://github.com/mobxjs/mobx-utils/blob/6cd6902d5a8dd745268eebace0a2d9477e286c16/lib/chunk-processor.js#L27-L52 "Source code on GitHub") | ||
@@ -451,3 +450,3 @@ `chunkProcessor` takes an observable array, observes it and calls `processor` | ||
[lib/now.js:30-39](https://github.com/mobxjs/mobx-utils/blob/a45d274dbac24c24b971c4b1acbed9302f965c56/lib/now.js#L30-L39 "Source code on GitHub") | ||
[lib/now.js:30-39](https://github.com/mobxjs/mobx-utils/blob/6cd6902d5a8dd745268eebace0a2d9477e286c16/lib/now.js#L30-L39 "Source code on GitHub") | ||
@@ -454,0 +453,0 @@ Returns the current date time as epoch number. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
81601
1262
3
464