mobx-utils
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -0,1 +1,5 @@ | ||
# 1.1.4 | ||
* Introduced `now(interval?)`, to get an observable that returns the current time at a specified interval | ||
# 1.1.3 | ||
@@ -2,0 +6,0 @@ |
import { IDisposer } from "./utils"; | ||
export interface IResource<T> { | ||
current(): T; | ||
dispose(): void; | ||
isAlive(): boolean; | ||
} | ||
/** | ||
@@ -65,6 +70,2 @@ * `fromResource` creates an observable which current state can be inspected using `.current()`, | ||
*/ | ||
export declare function fromResource<T>(subscriber: (sink: (newValue: T) => void) => void, unsubscriber?: IDisposer, initialValue?: T): { | ||
current(): T; | ||
dispose(): void; | ||
isAlive(): boolean; | ||
}; | ||
export declare function fromResource<T>(subscriber: (sink: (newValue: T) => void) => void, unsubscriber?: IDisposer, initialValue?: T): IResource<T>; |
@@ -10,2 +10,3 @@ export * from "./from-promise"; | ||
export * from "./chunk-processor"; | ||
export * from "./now"; | ||
export * from "./utils"; |
@@ -14,2 +14,3 @@ "use strict"; | ||
__export(require("./chunk-processor")); | ||
__export(require("./now")); | ||
__export(require("./utils")); |
@@ -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(5)),n(r(9)),n(r(6)),n(r(10)),n(r(4)),n(r(7)),n(r(8)),n(r(11)),n(r(3)),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,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,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var u=e.length-1;u>=0;u--)(o=e[u])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s},i=r(1),s=r(2),u=["model","reset","submit","isDirty","isPropertyDirty"],c=function(){function e(e){var t=this;this.model=e,this.localValues=i.asMap({}),s.invariant(i.isObservableObject(e),"createViewModel expects an observable object"),Object.keys(e).forEach(function(e){s.invariant(u.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)},o([i.computed],e.prototype,"isDirty",null),o([i.action],e.prototype,"submit",null),o([i.action],e.prototype,"reset",null),o([i.action],e.prototype,"resetProperty",null),e}();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 s(e,t,r)}var o=r(1),i=r(2);t.PENDING="pending",t.FULFILLED="fulfilled",t.REJECTED="rejected";var s=function(){function e(e,t,r){var n=this;void 0===t&&(t=void 0),void 0===r&&(r=i.IDENTITY),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){void 0===t&&(t=i.NOOP),void 0===r&&(r=void 0);var n=!1,s=!1,u=r,c=function(){n&&(n=!1,t())},a=new o.Atom("ResourceBasedObservable",function(){i.invariant(!n&&!s),n=!0,e(o.action("ResourceBasedObservable-sink",function(e){u=e,a.reportChanged()}))},c);return{current:function(){i.invariant(!s,"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"),u},dispose:function(){s=!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){void 0===r&&(r=1e4),void 0===n&&(n=function(){});var i=!1,s=setTimeout(function(){i||(u(),n())},r),u=o.when(e,function(){i=!0,clearTimeout(s),t()});return function(){clearTimeout(s),u()}}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,s=i.observable(r(t)),u=function(){return n||(n=!0,e(i.action("lazyObservable-fetch",function(e){s.set(e)}))),s.get()};return{current:u,refresh:function(){return n=!1,u()}}}var o=r(2),i=r(1);t.lazyObservable=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 s(e,t){return void 0===t&&(t=void 0),new a(e,t)}var u=this&&this.__decorate||function(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var u=e.length-1;u>=0;u--)(o=e[u])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s},c=r(1);t.toStream=i;var a=function(){function e(e,t){this.current=c.asReference(void 0),this.current=t,this.subscription=e.subscribe(this)}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()},u([c.observable],e.prototype,"current",void 0),e}();t.fromStream=s},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,s=!1,u=r,c=function(){n&&(n=!1,t())},a=new o.Atom("ResourceBasedObservable",function(){i.invariant(!n&&!s),n=!0,e(o.action("ResourceBasedObservable-sink",function(e){u=e,a.reportChanged()}))},c);return{current:function(){i.invariant(!s,"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"),u},dispose:function(){s=!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,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var u=e.length-1;u>=0;u--)(o=e[u])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s},i=r(1),s=r(2),u=["model","reset","submit","isDirty","isPropertyDirty"],c=function(){function e(e){var t=this;this.model=e,this.localValues=i.asMap({}),s.invariant(i.isObservableObject(e),"createViewModel expects an observable object"),Object.keys(e).forEach(function(e){s.invariant(u.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)},o([i.computed],e.prototype,"isDirty",null),o([i.action],e.prototype,"submit",null),o([i.action],e.prototype,"reset",null),o([i.action],e.prototype,"resetProperty",null),e}();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 s(e,t,r)}var o=r(1),i=r(2);t.PENDING="pending",t.FULFILLED="fulfilled",t.REJECTED="rejected";var s=function(){function e(e,t,r){var n=this;void 0===t&&(t=void 0),void 0===r&&(r=i.IDENTITY),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,s=setTimeout(function(){i||(u(),n())},r),u=o.when(e,function(){i=!0,clearTimeout(s),t()});return function(){clearTimeout(s),u()}}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,s=i.observable(r(t)),u=function(){return n||(n=!0,e(i.action("lazyObservable-fetch",function(e){s.set(e)}))),s.get()};return{current:u,refresh:function(){return n=!1,u()}}}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),u[e]||("number"==typeof e?u[e]=o(e):u[e]=i()),u[e].current()}function o(e){var t;return s.fromResource(function(r){t=setInterval(function(){return r(Date.now())},e)},function(){clearInterval(t)},Date.now())}function i(){var e=s.fromResource(function(t){function r(){window.requestAnimationFrame(function(){t(Date.now()),e.isAlive()&&r()})}r()},function(){},Date.now());return e}var s=r(3),u={};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 s(e,t){return void 0===t&&(t=void 0),new a(e,t)}var u=this&&this.__decorate||function(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var u=e.length-1;u>=0;u--)(o=e[u])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s},c=r(1);t.toStream=i;var a=function(){function e(e,t){this.current=c.asReference(void 0),this.current=t,this.subscription=e.subscribe(this)}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()},u([c.observable],e.prototype,"current",void 0),e}();t.fromStream=s},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.3", | ||
"version": "1.1.4", | ||
"description": "Utility functions and common patterns for MobX", | ||
@@ -5,0 +5,0 @@ "main": "lib/mobx-utils.js", |
@@ -25,3 +25,3 @@ # MobX-utils | ||
[lib/from-promise.js:103-107](https://github.com/mobxjs/mobx-utils/blob/197f8f8666eb54d6a1b2497f2bc6f81815316949/lib/from-promise.js#L103-L107 "Source code on GitHub") | ||
[lib/from-promise.js:103-107](https://github.com/mobxjs/mobx-utils/blob/05599baa08d22c5e1fc75caa7b767c26a2b3faaf/lib/from-promise.js#L103-L107 "Source code on GitHub") | ||
@@ -82,3 +82,3 @@ `fromPromise` takes a Promise and returns an object with 3 observable properties that track | ||
[lib/lazy-observable.js:37-58](https://github.com/mobxjs/mobx-utils/blob/197f8f8666eb54d6a1b2497f2bc6f81815316949/lib/lazy-observable.js#L37-L58 "Source code on GitHub") | ||
[lib/lazy-observable.js:37-58](https://github.com/mobxjs/mobx-utils/blob/05599baa08d22c5e1fc75caa7b767c26a2b3faaf/lib/lazy-observable.js#L37-L58 "Source code on GitHub") | ||
@@ -120,3 +120,3 @@ `lazyObservable` creates an observable around a `fetch` method that will not be invoked | ||
[lib/from-resource.js:67-101](https://github.com/mobxjs/mobx-utils/blob/197f8f8666eb54d6a1b2497f2bc6f81815316949/lib/from-resource.js#L67-L101 "Source code on GitHub") | ||
[lib/from-resource.js:67-101](https://github.com/mobxjs/mobx-utils/blob/05599baa08d22c5e1fc75caa7b767c26a2b3faaf/lib/from-resource.js#L67-L101 "Source code on GitHub") | ||
@@ -185,3 +185,3 @@ `fromResource` creates an observable which current state can be inspected using `.current()`, | ||
[lib/observable-stream.js:37-52](https://github.com/mobxjs/mobx-utils/blob/197f8f8666eb54d6a1b2497f2bc6f81815316949/lib/observable-stream.js#L37-L52 "Source code on GitHub") | ||
[lib/observable-stream.js:37-52](https://github.com/mobxjs/mobx-utils/blob/05599baa08d22c5e1fc75caa7b767c26a2b3faaf/lib/observable-stream.js#L37-L52 "Source code on GitHub") | ||
@@ -214,3 +214,3 @@ Converts an expression to an observable stream (a.k.a. TC 39 Observable / RxJS observable). | ||
[lib/observable-stream.js:104-107](https://github.com/mobxjs/mobx-utils/blob/197f8f8666eb54d6a1b2497f2bc6f81815316949/lib/observable-stream.js#L104-L107 "Source code on GitHub") | ||
[lib/observable-stream.js:104-107](https://github.com/mobxjs/mobx-utils/blob/05599baa08d22c5e1fc75caa7b767c26a2b3faaf/lib/observable-stream.js#L104-L107 "Source code on GitHub") | ||
@@ -242,3 +242,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/197f8f8666eb54d6a1b2497f2bc6f81815316949/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/05599baa08d22c5e1fc75caa7b767c26a2b3faaf/lib/create-view-model.js#L127-L129 "Source code on GitHub") | ||
@@ -294,3 +294,3 @@ `createViewModel` takes an object with observable properties (model) | ||
[lib/guarded-when.js:32-51](https://github.com/mobxjs/mobx-utils/blob/197f8f8666eb54d6a1b2497f2bc6f81815316949/lib/guarded-when.js#L32-L51 "Source code on GitHub") | ||
[lib/guarded-when.js:32-51](https://github.com/mobxjs/mobx-utils/blob/05599baa08d22c5e1fc75caa7b767c26a2b3faaf/lib/guarded-when.js#L32-L51 "Source code on GitHub") | ||
@@ -331,3 +331,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/197f8f8666eb54d6a1b2497f2bc6f81815316949/lib/keep-alive.js#L31-L36 "Source code on GitHub") | ||
[lib/keep-alive.js:31-36](https://github.com/mobxjs/mobx-utils/blob/05599baa08d22c5e1fc75caa7b767c26a2b3faaf/lib/keep-alive.js#L31-L36 "Source code on GitHub") | ||
@@ -355,3 +355,3 @@ **Parameters** | ||
[lib/keep-alive.js:31-36](https://github.com/mobxjs/mobx-utils/blob/197f8f8666eb54d6a1b2497f2bc6f81815316949/lib/keep-alive.js#L31-L36 "Source code on GitHub") | ||
[lib/keep-alive.js:31-36](https://github.com/mobxjs/mobx-utils/blob/05599baa08d22c5e1fc75caa7b767c26a2b3faaf/lib/keep-alive.js#L31-L36 "Source code on GitHub") | ||
@@ -383,3 +383,3 @@ MobX normally suspends any computed value that is not in use by any reaction, | ||
[lib/queue-processor.js:22-40](https://github.com/mobxjs/mobx-utils/blob/197f8f8666eb54d6a1b2497f2bc6f81815316949/lib/queue-processor.js#L22-L40 "Source code on GitHub") | ||
[lib/queue-processor.js:22-40](https://github.com/mobxjs/mobx-utils/blob/05599baa08d22c5e1fc75caa7b767c26a2b3faaf/lib/queue-processor.js#L22-L40 "Source code on GitHub") | ||
@@ -412,3 +412,3 @@ `queueProcessor` takes an observable array, observes it and calls `processor` | ||
[lib/chunk-processor.js:27-52](https://github.com/mobxjs/mobx-utils/blob/197f8f8666eb54d6a1b2497f2bc6f81815316949/lib/chunk-processor.js#L27-L52 "Source code on GitHub") | ||
[lib/chunk-processor.js:27-52](https://github.com/mobxjs/mobx-utils/blob/05599baa08d22c5e1fc75caa7b767c26a2b3faaf/lib/chunk-processor.js#L27-L52 "Source code on GitHub") | ||
@@ -443,1 +443,29 @@ `chunkProcessor` takes an observable array, observes it and calls `processor` | ||
Returns **IDisposer** stops the processor | ||
## now | ||
[lib/now.js:28-37](https://github.com/mobxjs/mobx-utils/blob/05599baa08d22c5e1fc75caa7b767c26a2b3faaf/lib/now.js#L28-L37 "Source code on GitHub") | ||
Returns the current date time as epoch number. | ||
The date time is read from an observable which is updated automatically after the given interval. | ||
So basically it treats time as an observable. | ||
The function takes an interval as parameter, which indicates how often `now()` will return a new value. | ||
If no interval is given, it will update each second. If "frame" is specified, it will update each time a | ||
`requestAnimationFrame` is available. | ||
Multiple clocks with the same interval will automatically be synchronized. | ||
**Parameters** | ||
- `interval` | ||
**Examples** | ||
```javascript | ||
const start = Date.now() | ||
autorun(() => { | ||
console.log("Seconds elapsed: ", (mobxUtils.now() - start) / 1000) | ||
}) | ||
``` |
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
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
80354
31
1232
460