storeon-observable
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -5,2 +5,6 @@ # Change Log | ||
## 1.0.1 | ||
- Return node.js v10 support | ||
- Fix epic execution order (by Paweł Majewski) ([3f567b](https://github.com/distolma/storeon-observable/commit/3f567b32da05ffb9d42210e920931738486e0127)) | ||
## 1.0.0 | ||
@@ -7,0 +11,0 @@ - node.js < v10 support is dropped |
@@ -56,3 +56,20 @@ (function (global, factory) { | ||
return new rxjs.Observable(subscriber => { | ||
subscriber.add(store.on('@dispatch', (_, event) => subscriber.next(toEvent(event[0], event[1])))); | ||
subscriber.add(store.on('@dispatch', (_, event) => { | ||
const nextEvent = toEvent(event[0], event[1]); | ||
if (event[2]) { | ||
// if there are some events handlers for this particular event | ||
// we will add to the end of handlers stack temporary event handler | ||
// which after all other events handlers (which are able to change the state) | ||
// will notify observable | ||
const un = store.on(event[0], () => { | ||
un(); | ||
subscriber.next(nextEvent); | ||
}); | ||
} | ||
else { | ||
// if there is no events handlers for this particular event | ||
// we can safely notify observable, as state will not change | ||
subscriber.next(nextEvent); | ||
} | ||
})); | ||
}); | ||
@@ -59,0 +76,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define(["exports","rxjs","rxjs/operators"],t):t((e=e||self).StoreonObservable={},e.rxjs,e.rxjs.operators)}(this,(function(e,t,r){"use strict";class o extends t.Observable{constructor(e){super(t=>{t.add(e.on("@changed",e=>{this._value=e,t.next(e)}))}),this._value=e.get()}get value(){return this._value}}function s(e,t){return void 0!==t?{type:e,payload:t}:{type:e}}const n=e=>new o(e),a=e=>new t.Observable(t=>{t.add(e.on("@dispatch",(e,r)=>t.next(s(r[0],r[1]))))});e.StateObservable=o,e.combineEpics=function(...e){return(r,o)=>t.merge(...e.map(e=>e(r,o)))},e.createEpicModule=e=>{const o=new t.BehaviorSubject(e);return e=>{const t=n(e),s=a(e);o.pipe(r.switchMap(e=>e(s,t))).subscribe(t=>e.dispatch.apply(e,[t.type,t.payload]))}},e.ofEvent=e=>t=>t.pipe(r.filter(t=>e===t.type)),e.toEvent=s,e.toEventObservable=a,e.toStateObservable=n,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define(["exports","rxjs","rxjs/operators"],t):t((e=e||self).StoreonObservable={},e.rxjs,e.rxjs.operators)}(this,(function(e,t,r){"use strict";class o extends t.Observable{constructor(e){super(t=>{t.add(e.on("@changed",e=>{this._value=e,t.next(e)}))}),this._value=e.get()}get value(){return this._value}}function s(e,t){return void 0!==t?{type:e,payload:t}:{type:e}}const n=e=>new o(e),a=e=>new t.Observable(t=>{t.add(e.on("@dispatch",(r,o)=>{const n=s(o[0],o[1]);if(o[2]){const r=e.on(o[0],()=>{r(),t.next(n)})}else t.next(n)}))});e.StateObservable=o,e.combineEpics=function(...e){return(r,o)=>t.merge(...e.map(e=>e(r,o)))},e.createEpicModule=e=>{const o=new t.BehaviorSubject(e);return e=>{const t=n(e),s=a(e);o.pipe(r.switchMap(e=>e(s,t))).subscribe(t=>e.dispatch.apply(e,[t.type,t.payload]))}},e.ofEvent=e=>t=>t.pipe(r.filter(t=>e===t.type)),e.toEvent=s,e.toEventObservable=a,e.toStateObservable=n,Object.defineProperty(e,"__esModule",{value:!0})})); |
@@ -33,3 +33,20 @@ "use strict"; | ||
return new rxjs_1.Observable(subscriber => { | ||
subscriber.add(store.on('@dispatch', (_, event) => subscriber.next(toEvent(event[0], event[1])))); | ||
subscriber.add(store.on('@dispatch', (_, event) => { | ||
const nextEvent = toEvent(event[0], event[1]); | ||
if (event[2]) { | ||
// if there are some events handlers for this particular event | ||
// we will add to the end of handlers stack temporary event handler | ||
// which after all other events handlers (which are able to change the state) | ||
// will notify observable | ||
const un = store.on(event[0], () => { | ||
un(); | ||
subscriber.next(nextEvent); | ||
}); | ||
} | ||
else { | ||
// if there is no events handlers for this particular event | ||
// we can safely notify observable, as state will not change | ||
subscriber.next(nextEvent); | ||
} | ||
})); | ||
}); | ||
@@ -36,0 +53,0 @@ }; |
@@ -29,3 +29,20 @@ import { Observable } from 'rxjs'; | ||
return new Observable(subscriber => { | ||
subscriber.add(store.on('@dispatch', (_, event) => subscriber.next(toEvent(event[0], event[1])))); | ||
subscriber.add(store.on('@dispatch', (_, event) => { | ||
const nextEvent = toEvent(event[0], event[1]); | ||
if (event[2]) { | ||
// if there are some events handlers for this particular event | ||
// we will add to the end of handlers stack temporary event handler | ||
// which after all other events handlers (which are able to change the state) | ||
// will notify observable | ||
const un = store.on(event[0], () => { | ||
un(); | ||
subscriber.next(nextEvent); | ||
}); | ||
} | ||
else { | ||
// if there is no events handlers for this particular event | ||
// we can safely notify observable, as state will not change | ||
subscriber.next(nextEvent); | ||
} | ||
})); | ||
}); | ||
@@ -32,0 +49,0 @@ }; |
{ | ||
"name": "storeon-observable", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "RxJS based module for Storeon which allows to create async actions", | ||
@@ -68,3 +68,3 @@ "main": "lib/cjs/index.js", | ||
"engines": { | ||
"node": ">10" | ||
"node": ">=10" | ||
}, | ||
@@ -74,7 +74,7 @@ "size-limit": [ | ||
"path": "lib/cjs/index.js", | ||
"limit": "510 B" | ||
"limit": "538 B" | ||
}, | ||
{ | ||
"path": "lib/esm/index.js", | ||
"limit": "383 B" | ||
"limit": "410 B" | ||
} | ||
@@ -81,0 +81,0 @@ ], |
@@ -20,3 +20,3 @@ # Storeon Observable | ||
**Via NPM:** This module has peer dependencie of `rxjs@6.x.x` and `storeon@2.x.x` which will has to be installed as well. | ||
**Via NPM:** This module has peer dependencie of `rxjs@6.x.x` and `storeon@3.x.x` which will has to be installed as well. | ||
```sh | ||
@@ -23,0 +23,0 @@ npm install -S storeon-observable |
Sorry, the diff of this file is not supported yet
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
36731
539