Comparing version 1.2.2 to 1.2.3
@@ -1,2 +0,2 @@ | ||
export * from './observable'; | ||
export * from './operators'; | ||
export * from "./models/types"; | ||
export * from "./operators"; |
@@ -1,2 +0,2 @@ | ||
export * from './observable'; | ||
export * from './operators'; | ||
export * from "./models/types"; | ||
export * from "./operators"; |
import { OperatorFunction, OperationResult } from "../models/operator"; | ||
import { Types } from "../models/types"; | ||
import { Observable } from "./observable"; | ||
export declare class MutableObservable<T = never> extends Observable<T> { | ||
export declare class MutableObservable<T = never> extends Observable<T> implements Types.MutableObservable<T> { | ||
private _preProcessOperations; | ||
@@ -5,0 +6,0 @@ constructor(...initialSequence: T[]); |
import { Observable } from "./observable"; | ||
import { OperatorFunction, OperationResult } from "../models/operator"; | ||
import { OnNext, Subscriber, Subscription } from "../models/subscription"; | ||
export declare class ObservableFork<T> extends Observable<T> { | ||
import { Types } from "../models"; | ||
export declare class ObservableFork<T> extends Observable<T> implements Types.ObservableFork<T> { | ||
private sourceObs$; | ||
@@ -6,0 +7,0 @@ private subscriptions; |
import { OperationResult, OperatorFunction } from "../models/operator"; | ||
import { OnNext, Subscriber, Subscription } from "../models/subscription"; | ||
export declare class Observable<T = never> { | ||
import { Types } from '../models/types'; | ||
export declare class Observable<T = never> implements Types.Observable<T> { | ||
protected _innerSequence: OperationResult<T>[]; | ||
@@ -5,0 +6,0 @@ protected _subscribers: Subscriber<T>[]; |
import { OperationResult, OperatorFunction } from "../../../models/operator"; | ||
import { Observable, ObservableFork } from "../../../observable"; | ||
import { Observable } from "../../../observable/observable"; | ||
import { ObservableFork } from "../../../observable/observable-fork"; | ||
export declare const fork: <T = never>(obs: Observable<T>, ...operators: OperatorFunction<T, OperationResult<any>>[]) => ObservableFork<any>; |
@@ -6,3 +6,3 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) { | ||
}; | ||
import { ObservableFork } from "../../../observable"; | ||
import { ObservableFork } from "../../../observable/observable-fork"; | ||
export var fork = function (obs) { | ||
@@ -9,0 +9,0 @@ var operators = []; |
@@ -1,2 +0,2 @@ | ||
import { MutableObservable } from "../../../observable"; | ||
import { MutableObservable } from "../../../observable/mutable-observable"; | ||
export declare const mutableFrom: <T = never>(values: T[]) => MutableObservable<T>; |
@@ -6,5 +6,5 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) { | ||
}; | ||
import { MutableObservable } from "../../../observable"; | ||
import { MutableObservable } from "../../../observable/mutable-observable"; | ||
export var mutableFrom = function (values) { | ||
return new (MutableObservable.bind.apply(MutableObservable, __spreadArray([void 0], values)))(); | ||
}; |
@@ -1,2 +0,2 @@ | ||
import { MutableObservable } from "../../../observable"; | ||
import { MutableObservable } from "../../../observable/mutable-observable"; | ||
export declare const mutable: <T = never>(...values: T[]) => MutableObservable<T>; |
@@ -6,3 +6,3 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) { | ||
}; | ||
import { MutableObservable } from "../../../observable"; | ||
import { MutableObservable } from "../../../observable/mutable-observable"; | ||
export var mutable = function () { | ||
@@ -9,0 +9,0 @@ var values = []; |
@@ -1,2 +0,2 @@ | ||
import { Observable } from "../../../observable"; | ||
import { Observable } from "../../../observable/observable"; | ||
export declare const of: <T = never>(...values: T[]) => Observable<T>; |
@@ -6,3 +6,3 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) { | ||
}; | ||
import { Observable } from "../../../observable"; | ||
import { Observable } from "../../../observable/observable"; | ||
export var of = function () { | ||
@@ -9,0 +9,0 @@ var values = []; |
@@ -1,2 +0,8 @@ | ||
import { MutableObservable } from "../../../observable"; | ||
import { MutableObservable } from "../../../observable/mutable-observable"; | ||
/** | ||
* @deprecated WILL BE REMOVED IN VERSION 1.2.4 | ||
* @param element | ||
* @param eventName | ||
* @returns | ||
*/ | ||
export declare const onEvent: (element: HTMLElement, eventName: keyof HTMLElementEventMap) => MutableObservable<Event>; |
@@ -1,2 +0,8 @@ | ||
import { MutableObservable } from "../../../observable"; | ||
import { MutableObservable } from "../../../observable/mutable-observable"; | ||
/** | ||
* @deprecated WILL BE REMOVED IN VERSION 1.2.4 | ||
* @param element | ||
* @param eventName | ||
* @returns | ||
*/ | ||
export var onEvent = function (element, eventName) { | ||
@@ -3,0 +9,0 @@ var obs$ = new MutableObservable(); |
import { OperationResult, OperatorFunction } from "../../../models/operator"; | ||
import { MutableObservable } from "../../../observable"; | ||
import { MutableObservable } from "../../../observable/mutable-observable"; | ||
export declare function preProcess<T = never>(...operations: OperatorFunction<any, OperationResult<T>>[]): MutableObservable<T>; |
@@ -1,2 +0,2 @@ | ||
import { MutableObservable } from "../../../observable"; | ||
import { MutableObservable } from "../../../observable/mutable-observable"; | ||
export function preProcess() { | ||
@@ -3,0 +3,0 @@ var _a; |
@@ -1,1 +0,1 @@ | ||
var t={d:(r,e)=>{for(var n in e)t.o(e,n)&&!t.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:e[n]})},o:(t,r)=>Object.prototype.hasOwnProperty.call(t,r)},r={};t.d(r,{IR:()=>l,y$:()=>p,T_:()=>b,gC:()=>_,hX:()=>v,rM:()=>P,Dp:()=>m,KJ:()=>w,UI:()=>d,Nl:()=>x,hL:()=>j,of:()=>N,Vl:()=>C,IH:()=>y,d_:()=>q,wt:()=>S,qn:()=>k,bw:()=>O,C4:()=>g});var e,n=function(){function t(t,r,e){this._value=t,this._flag=r,this._error=e}return Object.defineProperty(t.prototype,"value",{get:function(){return this._value},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"flag",{get:function(){return this._flag},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"error",{get:function(){return this._error},enumerable:!1,configurable:!0}),t.prototype.isUnwrapSwitch=function(){return this._flag===e.UnwrapSwitch},t.prototype.isMustStop=function(){return this._flag===e.MustStop},t.prototype.isFilterNotMatched=function(){return this._flag===e.FilterNotMatched},t.prototype.isOperationError=function(){return this._flag===e.OperationError},t}();function o(t){return"function"==typeof t}function i(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return t.filter((function(t){return o(t)}))}!function(t){t.UnwrapSwitch="UnwrapSwitch",t.MustStop="MustStop",t.FilterNotMatched="FilterNotMatched",t.OperationError="OperationError"}(e||(e={}));var u=function(){function t(t){this._unsubscribeCallback=t}return t.prototype.unsubscribe=function(){this._unsubscribeCallback&&this._unsubscribeCallback()},t}();function s(t){return!o(t)&&function(t){for(var r=[],e=1;e<arguments.length;e++)r[e-1]=arguments[e];return r.some((function(r){return void 0!==t[r]&&null!==t[r]&&o(t[r])}))}(t,"next","error","complete")}function c(t,r,e){var n={next:t,error:r,complete:e};if(!s(n))throw new Error("Please provide functions for next, error and complete");return n}new u;var a,p=function(){function t(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];this._subscribers=[],this._isComplete=!0,this._innerSequence=t.map((function(t){return new n(t)}))}return t.prototype.pipe=function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];for(var i=new t,u=[],s=this._innerSequence,c=0,a=s.length;c<a&&!s[c].isMustStop();c++)try{var p=this._executeOperations(s[c].value,r);p.isFilterNotMatched()||u.push(p)}catch(t){u.push(new n(s[c].value,e.OperationError,t)),c=a}return i._innerSequence=u,i},t.prototype.subscribe=function(t){var r=this;if(!o(t)&&!s(t))throw new Error("Please provide either a function or a Subscriber");var e=s(t)?t:c(t);return this._subscribers.push(e),this.executeSubscriber(e,this._innerSequence),new u((function(){return r._subscribers=r._subscribers.filter((function(r){return r!==t}))}))},t.prototype.executeSubscriber=function(t,r){for(var e=function(e,o){var i=r[e];return i.isOperationError()?(n._error=i.error,(t.error||function(){throw i.error})(i.error),"break"):i.isFilterNotMatched()?"continue":i.isMustStop()?"break":void(t.next&&t.next(i.value))},n=this,o=0,i=r.length;o<i&&"break"!==e(o);o++);this._isComplete&&t.complete&&t.complete()},t.prototype._computeValue=function(t){for(var r,o=[],i=1;i<arguments.length;i++)o[i-1]=arguments[i];for(var u=new n(t),s=0;s<o.length;s++)switch((u=o[s](u.value)).flag){case e.FilterNotMatched:case e.MustStop:s=o.length;break;case e.UnwrapSwitch:u=new n(null===(r=u.value._innerSequence.pop())||void 0===r?void 0:r.value)}return u},t.prototype._executeOperations=function(t,r){return this._computeValue.apply(this,function(t,r){for(var e=0,n=r.length,o=t.length;e<n;e++,o++)t[o]=r[e];return t}([t],i.apply(void 0,r)))},t}(),f=(a=function(t,r){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=r[e])})(t,r)},function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function e(){this.constructor=t}a(t,r),t.prototype=null===r?Object.create(r):(e.prototype=r.prototype,new e)}),l=function(t){function r(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var n=t.apply(this,r)||this;return n._preProcessOperations=[],n._isComplete=!1,n}return f(r,t),r.prototype.close=function(){this._isComplete||(this._isComplete=!0,this._subscribers.forEach((function(t){t.complete&&t.complete()})))},r.prototype.compile=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];if(this._isComplete)return this;var e=this._buildNewSequence(this._innerSequence.filter((function(t){return!t.isOperationError()})).map((function(t){return t.value})),t).filter((function(t){return!t.isMustStop()})),n=e.findIndex((function(t){return t.isOperationError()}));return n>-1?(this._innerSequence=e.slice(0,n),this.next.apply(this,this._innerSequence.map((function(t){return t.value}))),this._innerSequence.push(e[n]),this._triggerExecution([e[n]],this._subscribers),this):this.next.apply(this,(this._innerSequence=e).map((function(t){return t.value})))},r.prototype.next=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return this._isComplete||(this._innerSequence=this._buildNewSequence(t,this._preProcessOperations),this._triggerExecution(this._innerSequence,this._subscribers)),this},r.prototype._buildNewSequence=function(t,r){for(var o=[],i=0,u=t.length;i<u;i++)try{var s=this._executeOperations(t[i],r);if(s.isMustStop()){o.push(s);break}s.isFilterNotMatched()||o.push(s)}catch(r){this._error=r,o.push(new n(t[i],e.OperationError,r)),i=u}return o},r.prototype._triggerExecution=function(t,r){var e=this;r.forEach((function(r){return e.executeSubscriber(r,t)}))},r}(p),h=function(){var t=function(r,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=r[e])})(r,e)};return function(r,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=r}t(r,e),r.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),b=function(t){function r(r){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var o=t.call(this)||this;return o.sourceObs$=r,o.subscriptions=[],o.operators=[],o.operators=e,o._isComplete=r._isComplete,o.sourceObs$.subscribe({next:function(t){o._subscribers.forEach((function(r){if(r.next){var n=o._executeOperations(t,e);if(!n.isFilterNotMatched()&&!n.isMustStop())return r.next(n.value);n.isMustStop()&&o.close()}}))},error:function(t){o._error=t,o._subscribers.forEach((function(r){return r.error&&r.error(t)}))},complete:function(){o._isComplete=!0,o.unsubscribe(),o._subscribers.forEach((function(t){return t.complete&&t.complete()}))}}),o}return h(r,t),r.prototype.subscribe=function(t){var r=this;if(!o(t)&&!s(t))throw new Error("Please provide either a function or a Subscriber");var i=s(t)?t:c(t);this._subscribers.push(i);for(var a=[],p=this.sourceObs$._innerSequence,f=0,l=p.length;f<l;f++)try{a.push(this._executeOperations(p[f].value,this.operators))}catch(t){a.push(new n(p[f].value,e.OperationError,t)),f=l}return this.executeSubscriber(i,a),new u((function(){return r._subscribers=r._subscribers.filter((function(r){return r!==t}))}))},r.prototype.close=function(){this._subscribers.forEach((function(t){return t.complete&&t.complete()})),this.unsubscribe()},r.prototype.unsubscribe=function(){this.subscriptions.forEach((function(t){return t.unsubscribe()}))},r}(p),v=function(t){return function(r){return new n(r,t(r)?void 0:e.FilterNotMatched)}},_=function(t){var r=!1;return function(o){return new n(o,(r=r||v(t)(o).isFilterNotMatched())?e.MustStop:void 0)}},w=function(t,r,e){return function(n){var o=v(t)(n),i=o.isFilterNotMatched()?null!=e?e:[]:r,u=i.shift();return u?i.reduce((function(t,r){return r(t.value)}),u(n)):o}},y=function(t){var r=!1;return function(o){return r?new n(o,e.MustStop):!t||t(o)?(r=!0,new n(o)):new n(o,e.FilterNotMatched)}},g=function(t){var r=!1;return function(o){return new n(o,(r=r||!v(t)(o).isFilterNotMatched())?e.MustStop:void 0)}},d=function(t){return function(r){return new n(t(r))}};function S(t){return function(r){return new n(t(r),e.UnwrapSwitch)}}var O=function(t){return function(r){return t(r),new n(r)}},m=function(t){return new(p.bind.apply(p,function(t,r){for(var e=0,n=r.length,o=t.length;e<n;e++,o++)t[o]=r[e];return t}([void 0],t)))},M=function(t,r){for(var e=0,n=r.length,o=t.length;e<n;e++,o++)t[o]=r[e];return t},x=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return new(l.bind.apply(l,M([void 0],t)))},E=function(t,r){for(var e=0,n=r.length,o=t.length;e<n;e++,o++)t[o]=r[e];return t},N=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return new(p.bind.apply(p,E([void 0],t)))},C=function(t,r){var e=new l;return t.addEventListener(r,(function(t){return e.next(t)})),e};function q(){for(var t,r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var n=new l;return(t=n._preProcessOperations).push.apply(t,r),n}var F=function(t,r){for(var e=0,n=r.length,o=t.length;e<n;e++,o++)t[o]=r[e];return t},P=function(t){for(var r=[],e=1;e<arguments.length;e++)r[e-1]=arguments[e];var n=new(b.bind.apply(b,F([void 0,t],r)));return n},j=function(t){var r=0;return function(o){return++r===t?new n(o):new n(o,r<t?e.FilterNotMatched:e.MustStop)}},k=function(t){var r=0;return function(o){return++r>t?new n(o,e.MustStop):new n(o)}},U=r.IR,I=r.y$,$=r.T_,L=r.gC,T=r.hX,V=r.rM,A=r.Dp,D=r.KJ,H=r.UI,J=r.Nl,K=r.hL,R=r.of,X=r.Vl,z=r.IH,B=r.d_,G=r.wt,Q=r.qn,W=r.bw,Y=r.C4;export{U as MutableObservable,I as Observable,$ as ObservableFork,L as asLongAs,T as filter,V as fork,A as from,D as ifElse,H as map,J as mutable,K as nth,R as of,X as onEvent,z as once,B as preProcess,G as switchMap,Q as take,W as tap,Y as until}; | ||
var t={d:(r,e)=>{for(var n in e)t.o(e,n)&&!t.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:e[n]})},o:(t,r)=>Object.prototype.hasOwnProperty.call(t,r)},r={};t.d(r,{gC:()=>i,hX:()=>o,rM:()=>F,Dp:()=>g,KJ:()=>u,UI:()=>a,Nl:()=>O,hL:()=>j,of:()=>x,Vl:()=>E,IH:()=>s,d_:()=>N,wt:()=>p,qn:()=>k,bw:()=>f,C4:()=>c});var e,n=function(){function t(t,r,e){this._value=t,this._flag=r,this._error=e}return Object.defineProperty(t.prototype,"value",{get:function(){return this._value},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"flag",{get:function(){return this._flag},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"error",{get:function(){return this._error},enumerable:!1,configurable:!0}),t.prototype.isUnwrapSwitch=function(){return this._flag===e.UnwrapSwitch},t.prototype.isMustStop=function(){return this._flag===e.MustStop},t.prototype.isFilterNotMatched=function(){return this._flag===e.FilterNotMatched},t.prototype.isOperationError=function(){return this._flag===e.OperationError},t}();!function(t){t.UnwrapSwitch="UnwrapSwitch",t.MustStop="MustStop",t.FilterNotMatched="FilterNotMatched",t.OperationError="OperationError"}(e||(e={}));var o=function(t){return function(r){return new n(r,t(r)?void 0:e.FilterNotMatched)}},i=function(t){var r=!1;return function(i){return new n(i,(r=r||o(t)(i).isFilterNotMatched())?e.MustStop:void 0)}},u=function(t,r,e){return function(n){var i=o(t)(n),u=i.isFilterNotMatched()?null!=e?e:[]:r,s=u.shift();return s?u.reduce((function(t,r){return r(t.value)}),s(n)):i}},s=function(t){var r=!1;return function(o){return r?new n(o,e.MustStop):!t||t(o)?(r=!0,new n(o)):new n(o,e.FilterNotMatched)}},c=function(t){var r=!1;return function(i){return new n(i,(r=r||!o(t)(i).isFilterNotMatched())?e.MustStop:void 0)}},a=function(t){return function(r){return new n(t(r))}};function p(t){return function(r){return new n(t(r),e.UnwrapSwitch)}}var f=function(t){return function(r){return t(r),new n(r)}};function l(t){return"function"==typeof t}function h(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return t.filter((function(t){return l(t)}))}var b=function(){function t(t){this._unsubscribeCallback=t}return t.prototype.unsubscribe=function(){this._unsubscribeCallback&&this._unsubscribeCallback()},t}();function v(t){return!l(t)&&function(t){for(var r=[],e=1;e<arguments.length;e++)r[e-1]=arguments[e];return r.some((function(r){return void 0!==t[r]&&null!==t[r]&&l(t[r])}))}(t,"next","error","complete")}function _(t,r,e){var n={next:t,error:r,complete:e};if(!v(n))throw new Error("Please provide functions for next, error and complete");return n}new b;var w,y=function(){function t(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];this._subscribers=[],this._isComplete=!0,this._innerSequence=t.map((function(t){return new n(t)}))}return t.prototype.pipe=function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];for(var i=new t,u=[],s=this._innerSequence,c=0,a=s.length;c<a&&!s[c].isMustStop();c++)try{var p=this._executeOperations(s[c].value,r);p.isFilterNotMatched()||u.push(p)}catch(t){u.push(new n(s[c].value,e.OperationError,t)),c=a}return i._innerSequence=u,i},t.prototype.subscribe=function(t){var r=this;if(!l(t)&&!v(t))throw new Error("Please provide either a function or a Subscriber");var e=v(t)?t:_(t);return this._subscribers.push(e),this.executeSubscriber(e,this._innerSequence),new b((function(){return r._subscribers=r._subscribers.filter((function(r){return r!==t}))}))},t.prototype.executeSubscriber=function(t,r){for(var e=function(e,o){var i=r[e];return i.isOperationError()?(n._error=i.error,(t.error||function(){throw i.error})(i.error),"break"):i.isFilterNotMatched()?"continue":i.isMustStop()?"break":void(t.next&&t.next(i.value))},n=this,o=0,i=r.length;o<i&&"break"!==e(o);o++);this._isComplete&&t.complete&&t.complete()},t.prototype._computeValue=function(t){for(var r,o=[],i=1;i<arguments.length;i++)o[i-1]=arguments[i];for(var u=new n(t),s=0;s<o.length;s++)switch((u=o[s](u.value)).flag){case e.FilterNotMatched:case e.MustStop:s=o.length;break;case e.UnwrapSwitch:u=new n(null===(r=u.value._innerSequence.pop())||void 0===r?void 0:r.value)}return u},t.prototype._executeOperations=function(t,r){return this._computeValue.apply(this,function(t,r){for(var e=0,n=r.length,o=t.length;e<n;e++,o++)t[o]=r[e];return t}([t],h.apply(void 0,r)))},t}(),g=function(t){return new(y.bind.apply(y,function(t,r){for(var e=0,n=r.length,o=t.length;e<n;e++,o++)t[o]=r[e];return t}([void 0],t)))},d=(w=function(t,r){return(w=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=r[e])})(t,r)},function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function e(){this.constructor=t}w(t,r),t.prototype=null===r?Object.create(r):(e.prototype=r.prototype,new e)}),S=function(t){function r(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var n=t.apply(this,r)||this;return n._preProcessOperations=[],n._isComplete=!1,n}return d(r,t),r.prototype.close=function(){this._isComplete||(this._isComplete=!0,this._subscribers.forEach((function(t){t.complete&&t.complete()})))},r.prototype.compile=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];if(this._isComplete)return this;var e=this._buildNewSequence(this._innerSequence.filter((function(t){return!t.isOperationError()})).map((function(t){return t.value})),t).filter((function(t){return!t.isMustStop()})),n=e.findIndex((function(t){return t.isOperationError()}));return n>-1?(this._innerSequence=e.slice(0,n),this.next.apply(this,this._innerSequence.map((function(t){return t.value}))),this._innerSequence.push(e[n]),this._triggerExecution([e[n]],this._subscribers),this):this.next.apply(this,(this._innerSequence=e).map((function(t){return t.value})))},r.prototype.next=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return this._isComplete||(this._innerSequence=this._buildNewSequence(t,this._preProcessOperations),this._triggerExecution(this._innerSequence,this._subscribers)),this},r.prototype._buildNewSequence=function(t,r){for(var o=[],i=0,u=t.length;i<u;i++)try{var s=this._executeOperations(t[i],r);if(s.isMustStop()){o.push(s);break}s.isFilterNotMatched()||o.push(s)}catch(r){this._error=r,o.push(new n(t[i],e.OperationError,r)),i=u}return o},r.prototype._triggerExecution=function(t,r){var e=this;r.forEach((function(r){return e.executeSubscriber(r,t)}))},r}(y),m=function(t,r){for(var e=0,n=r.length,o=t.length;e<n;e++,o++)t[o]=r[e];return t},O=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return new(S.bind.apply(S,m([void 0],t)))},M=function(t,r){for(var e=0,n=r.length,o=t.length;e<n;e++,o++)t[o]=r[e];return t},x=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return new(y.bind.apply(y,M([void 0],t)))},E=function(t,r){var e=new S;return t.addEventListener(r,(function(t){return e.next(t)})),e};function N(){for(var t,r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var n=new S;return(t=n._preProcessOperations).push.apply(t,r),n}var C=function(){var t=function(r,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=r[e])})(r,e)};return function(r,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=r}t(r,e),r.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),q=function(t){function r(r){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var o=t.call(this)||this;return o.sourceObs$=r,o.subscriptions=[],o.operators=[],o.operators=e,o._isComplete=r._isComplete,o.sourceObs$.subscribe({next:function(t){o._subscribers.forEach((function(r){if(r.next){var n=o._executeOperations(t,e);if(!n.isFilterNotMatched()&&!n.isMustStop())return r.next(n.value);n.isMustStop()&&o.close()}}))},error:function(t){o._error=t,o._subscribers.forEach((function(r){return r.error&&r.error(t)}))},complete:function(){o._isComplete=!0,o.unsubscribe(),o._subscribers.forEach((function(t){return t.complete&&t.complete()}))}}),o}return C(r,t),r.prototype.subscribe=function(t){var r=this;if(!l(t)&&!v(t))throw new Error("Please provide either a function or a Subscriber");var o=v(t)?t:_(t);this._subscribers.push(o);for(var i=[],u=this.sourceObs$._innerSequence,s=0,c=u.length;s<c;s++)try{i.push(this._executeOperations(u[s].value,this.operators))}catch(t){i.push(new n(u[s].value,e.OperationError,t)),s=c}return this.executeSubscriber(o,i),new b((function(){return r._subscribers=r._subscribers.filter((function(r){return r!==t}))}))},r.prototype.close=function(){this._subscribers.forEach((function(t){return t.complete&&t.complete()})),this.unsubscribe()},r.prototype.unsubscribe=function(){this.subscriptions.forEach((function(t){return t.unsubscribe()}))},r}(y),P=function(t,r){for(var e=0,n=r.length,o=t.length;e<n;e++,o++)t[o]=r[e];return t},F=function(t){for(var r=[],e=1;e<arguments.length;e++)r[e-1]=arguments[e];var n=new(q.bind.apply(q,P([void 0,t],r)));return n},j=function(t){var r=0;return function(o){return++r===t?new n(o):new n(o,r<t?e.FilterNotMatched:e.MustStop)}},k=function(t){var r=0;return function(o){return++r>t?new n(o,e.MustStop):new n(o)}},U=r.gC,I=r.hX,L=r.rM,V=r.Dp,A=r.KJ,$=r.UI,D=r.Nl,H=r.hL,J=r.of,K=r.Vl,T=r.IH,X=r.d_,z=r.wt,B=r.qn,G=r.bw,Q=r.C4;export{U as asLongAs,I as filter,L as fork,V as from,A as ifElse,$ as map,D as mutable,H as nth,J as of,K as onEvent,T as once,X as preProcess,z as switchMap,B as take,G as tap,Q as until}; |
{ | ||
"name": "fleuvejs", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "A simple JavaScript Library for Observables", | ||
"main": "build/index.js", | ||
"scripts": { | ||
"build": "tsc --project tsconfig.json && npx webpack", | ||
"build": "rm -rf ./build && tsc --project tsconfig.json && npx webpack", | ||
"test": "jest" | ||
@@ -9,0 +9,0 @@ }, |
@@ -83,2 +83,3 @@ # FleuveJS | ||
### Add an event listener | ||
*Do not use anymore: will be deprecated and maybe replaced by a better implementation.* | ||
You can bind users interactions to an Observable. | ||
@@ -85,0 +86,0 @@ |
@@ -1,2 +0,2 @@ | ||
export * from './observable'; | ||
export * from './operators'; | ||
export * from "./models/types"; | ||
export * from "./operators"; |
@@ -7,5 +7,6 @@ import { | ||
import { Subscriber } from "../models/subscription"; | ||
import { Types } from "../models/types"; | ||
import { Observable } from "./observable"; | ||
export class MutableObservable<T = never> extends Observable<T> { | ||
export class MutableObservable<T = never> extends Observable<T> implements Types.MutableObservable<T> { | ||
private _preProcessOperations: OperatorFunction<T, any>[] = []; | ||
@@ -12,0 +13,0 @@ |
@@ -11,4 +11,5 @@ import { Observable } from "./observable"; | ||
} from "../models/subscription"; | ||
import { Types } from "../models"; | ||
export class ObservableFork<T> extends Observable<T> { | ||
export class ObservableFork<T> extends Observable<T> implements Types.ObservableFork<T> { | ||
private subscriptions: Subscription[] = []; | ||
@@ -15,0 +16,0 @@ private operators: OperatorFunction<T, OperationResult<any>>[] = []; |
@@ -17,4 +17,6 @@ import { filterNonFunctions, isFunction } from "../helpers/function.helper"; | ||
export class Observable<T = never> { | ||
import {Types} from '../models/types'; | ||
export class Observable<T = never> implements Types.Observable<T> { | ||
protected _innerSequence: OperationResult<T>[]; | ||
@@ -21,0 +23,0 @@ protected _subscribers: Subscriber<T>[] = []; |
import { OperationResult, OperatorFunction } from "../../../models/operator"; | ||
import { Observable, ObservableFork } from "../../../observable"; | ||
import { Observable } from "../../../observable/observable"; | ||
import { ObservableFork } from "../../../observable/observable-fork"; | ||
@@ -4,0 +5,0 @@ export const fork = function <T = never>( |
@@ -1,2 +0,2 @@ | ||
import { MutableObservable } from "../../../observable"; | ||
import { MutableObservable } from "../../../observable/mutable-observable"; | ||
@@ -3,0 +3,0 @@ export const mutableFrom = function<T = never>(values: T[]): MutableObservable<T> { |
@@ -1,2 +0,2 @@ | ||
import { MutableObservable } from "../../../observable"; | ||
import { MutableObservable } from "../../../observable/mutable-observable"; | ||
@@ -3,0 +3,0 @@ export const mutable = function<T = never>(...values: T[]): MutableObservable<T> { |
@@ -1,2 +0,2 @@ | ||
import { Observable } from "../../../observable"; | ||
import { Observable } from "../../../observable/observable"; | ||
@@ -3,0 +3,0 @@ export const of = function<T = never>(...values: T[]): Observable<T> { |
@@ -1,7 +0,13 @@ | ||
import { MutableObservable } from "../../../observable"; | ||
import { MutableObservable } from "../../../observable/mutable-observable"; | ||
export const onEvent = (element: HTMLElement, eventName: keyof HTMLElementEventMap) => { | ||
/** | ||
* @deprecated WILL BE REMOVED IN VERSION 1.2.4 | ||
* @param element | ||
* @param eventName | ||
* @returns | ||
*/ | ||
export const onEvent = (element: HTMLElement, eventName: keyof HTMLElementEventMap): MutableObservable<Event> => { | ||
const obs$ = new MutableObservable<Event>(); | ||
element.addEventListener(eventName, (e: Event) => obs$.next(e)); | ||
return obs$; | ||
} | ||
} |
import { OperationResult, OperatorFunction } from "../../../models/operator"; | ||
import { MutableObservable } from "../../../observable"; | ||
import { MutableObservable } from "../../../observable/mutable-observable"; | ||
@@ -4,0 +4,0 @@ export function preProcess<T = never>(...operations: OperatorFunction<any, OperationResult<T>>[]): MutableObservable<T> { |
@@ -1,11 +0,8 @@ | ||
import { MutableObservable } from '../../bundle/observable.bundle.js'; | ||
import { mutable, map } from '../../bundle/observable.bundle.js'; | ||
const counter$ = new MutableObservable(0); | ||
const counter$ = mutable(0); | ||
const counter = document.getElementById('counter'); | ||
counter$.subscribe((count) => { | ||
counter.innerText = count; | ||
}); | ||
counter$.addEventListener('#increment', 'click', (x) => counter$.next(x + 1)); | ||
counter$.addEventListener('#decrement', 'click', (x) => counter$.next(x - 1)); | ||
counter$.subscribe((count) => { counter.innerText = count;}); | ||
document.getElementById('increment').addEventListener('click', () => counter$.compile(map(x => x + 1))); | ||
document.getElementById('decrement').addEventListener('click', () => counter$.compile(map(x => x - 1))); |
@@ -1,7 +0,7 @@ | ||
import {MutableObservable, filter} from '../../bundle/observable.bundle.js'; | ||
import {filter, mutable, fork} from '../../bundle/observable.bundle.js'; | ||
const result = document.getElementById('results'); | ||
const obs$ = new MutableObservable(12); | ||
const forked$ = obs$.fork(filter(x => x > 15)); | ||
const obs$ = mutable(12); | ||
const forked$ = fork(obs$, filter(x => x > 15)); | ||
forked$.subscribe(x => result.innerText += `${x}\n`); // nothing would happen at first | ||
obs$.next(20); // now, 20 would be printed in the browser's console |
@@ -1,6 +0,6 @@ | ||
import {Observable, map, filter} from '../../bundle/observable.bundle.js'; | ||
import {map, filter, of} from '../../bundle/observable.bundle.js'; | ||
const result = document.getElementById('results'); | ||
const obs$ = new Observable(12); | ||
const obs$ = of(12); | ||
@@ -7,0 +7,0 @@ obs$.pipe(map(x => x * 2)).subscribe((value) => result.innerText += `Mapped value is ${value}`); |
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
126691
136
2363
372