evg_observable 1.4.37 → 1.4.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/repo/evg_observable.js +1 -0
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(()=>{"use strict";var e={909:(e,s,i)=>{s.P=void 0;const t=i(594);s.P=class{constructor(){this.list=[],this._isDestroyed=!1}collect(...e){this._isDestroyed||this.list.push(...e)}unsubscribe(e){this._isDestroyed||(null==e||e.unsubscribe(),(0,t.quickDeleteFromArray)(this.list,e))}unsubscribeAll(){if(!this._isDestroyed)for(;this.list.length>0;)this.unsubscribe(this.list.pop())}size(){return this._isDestroyed?0:this.list.length}destroy(){this.unsubscribeAll(),this.list.length=0,this.list=0,this._isDestroyed=!0}get isDestroyed(){return this._isDestroyed}}},594:(e,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.positiveCallback=s.negativeCallback=s.quickDeleteFromArray=s.deleteFromArray=void 0,s.deleteFromArray=function(e,s){const i=e.indexOf(s);return-1!==i&&(e.splice(i,1),!0)},s.quickDeleteFromArray=function(e,s){const i=e.indexOf(s);return-1!==i&&(e[i]=e[e.length-1],e.length=e.length-1,!0)},s.negativeCallback=()=>!1,s.positiveCallback=()=>!0},637:(e,s,i)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.Observable=s.SubscribeObject=void 0;const t=i(594);class r{constructor(e,s){this.isMarkedForUnsubscribe=!1,this.errorHandler=(e,s)=>{console.log(`(Unit of SubscribeObject).send(${e}) ERROR:`,s)},this._order=0,this.isListenPaused=!1,this.once={isOnce:!1,isFinished:!1},this.unsubscribeByNegativeCondition=null,this.unsubscribeByPositiveCondition=null,this.emitByNegativeCondition=null,this.emitByPositiveCondition=null,this.emitMatchCondition=null,this.isPipe=!1,this.observable=e,this.isPipe=!!s}static callbackSend(e,s){const i=s.listener;if(i)switch(!0){case!s.observable:return void s.unsubscribe();case s.isListenPaused:return;case!s.isPipe:return void i(e);case s.once.isOnce:s.once.isFinished=!0,i(e),s.unsubscribe();break;case!!s.unsubscribeByNegativeCondition:if(!s.unsubscribeByNegativeCondition(e))return s.unsubscribeByNegativeCondition=null,void s.unsubscribe();i(e);break;case!!s.unsubscribeByPositiveCondition:if(s.unsubscribeByPositiveCondition(e))return s.unsubscribeByPositiveCondition=null,void s.unsubscribe();i(e);break;case!!s.emitByNegativeCondition:!s.emitByNegativeCondition(e)&&i(e);break;case!!s.emitByPositiveCondition:s.emitByPositiveCondition(e)&&i(e);break;case!!s.emitMatchCondition:s.emitMatchCondition(e)===e&&i(e)}else s.unsubscribe()}subscribe(e,s){return this.listener=e,s&&(this.errorHandler=s),this}unsubscribe(){this.observable&&(this.observable.unSubscribe(this),this.observable=0,this.listener=0)}send(e){try{r.callbackSend(e,this)}catch(s){this.errorHandler(e,s)}}setOnce(){return this.once.isOnce=!0,this}unsubscribeByNegative(e){return this.unsubscribeByNegativeCondition=e||t.negativeCallback,this}unsubscribeByPositive(e){return this.unsubscribeByPositiveCondition=e||t.positiveCallback,this}emitByNegative(e){return this.emitByNegativeCondition=e||t.positiveCallback,this}emitByPositive(e){return this.emitByPositiveCondition=e||t.negativeCallback,this}emitMatch(e){const s=typeof e;return"function"!==s&&(e=()=>`ERROR CONDITION TYPE ${s}, CONTROL STATE ${this.observable&&!this.observable.getValue()}`),this.emitMatchCondition=e,this}resume(){this.isListenPaused=!1}pause(){this.isListenPaused=!0}get order(){return this._order}set order(e){this._order=e}}s.SubscribeObject=r,s.Observable=class{constructor(e){this.value=e,this.listeners=[],this._isEnable=!0,this._isDestroyed=!1,this.isNextProcess=!1,this.listenersForUnsubscribe=[]}disable(){this._isEnable=!1}enable(){this._isEnable=!0}get isEnable(){return this._isEnable}next(e){if(this._isDestroyed)return;if(!this._isEnable)return;this.isNextProcess=!0,this.value=e;const s=this.listeners.length;for(let i=0;i<s;i++)this.listeners[i].send(e);this.isNextProcess=!1,this.listenersForUnsubscribe.length&&this.handleListenersForUnsubscribe()}stream(e){if(!this._isDestroyed&&this._isEnable)for(let s=0;s<e.length;s++)this.next(e[s])}handleListenersForUnsubscribe(){const e=this.listenersForUnsubscribe.length;for(let s=0;s<e;s++){const e=this.listenersForUnsubscribe[s];this.unSubscribe(e)}this.listenersForUnsubscribe.length=0}unSubscribe(e){if(!this._isDestroyed){if(this.isNextProcess&&e){const s=e;return!s.isMarkedForUnsubscribe&&this.listenersForUnsubscribe.push(e),void(s.isMarkedForUnsubscribe=!0)}this.listeners&&(0,t.quickDeleteFromArray)(this.listeners,e)}}destroy(){this.value=0,this.unsubscribeAll(),this.listeners=0,this._isDestroyed=!0}unsubscribeAll(){this._isDestroyed||(this.listeners.length=0)}getValue(){if(!this._isDestroyed)return this.value}size(){return this._isDestroyed?0:this.listeners.length}subscribe(e,s){if(this._isDestroyed)return;if(!e)return;const i=new r(this,!1);return i.subscribe(e,s),this.listeners.push(i),i}pipe(){if(this._isDestroyed)return;const e=new r(this,!0);return this.listeners.push(e),e}get isDestroyed(){return this._isDestroyed}}},546:(e,s,i)=>{s.Nc=void 0;const t=i(637),r=i(594);class n extends t.SubscribeObject{constructor(e,s){super(e,s)}get order(){return this._order}set order(e){!this.observable||this.observable&&this.observable.isDestroyed?this._order=void 0:(this._order=e,this.observable.sortByOrder())}subscribe(e,s){return this.listener=e,s&&(this.errorHandler=s),this}setOnce(){return super.setOnce()}unsubscribeByNegative(e){return super.unsubscribeByNegative(e)}unsubscribeByPositive(e){return super.unsubscribeByPositive(e)}emitByNegative(e){return super.emitByNegative(e)}emitByPositive(e){return super.emitByPositive(e)}emitMatch(e){return super.emitMatch(e)}}class o extends t.Observable{sortByOrder(){return!this._isDestroyed&&(this.listeners.sort(((e,s)=>e.order>s.order?1:e.order<s.order?-1:0)),!0)}subscribe(e,s){if(this._isDestroyed)return;if(!e)return;const i=new n(this,!1);return i.subscribe(e,s),this.listeners.push(i),i}pipe(){if(this._isDestroyed)return;const e=new n(this,!0);return this.listeners.push(e),e}unSubscribe(e){if(!this._isDestroyed){if(this.isNextProcess&&e){const s=e;return!s.isMarkedForUnsubscribe&&this.listenersForUnsubscribe.push(e),void(s.isMarkedForUnsubscribe=!0)}this.listeners&&(0,r.deleteFromArray)(this.listeners,e)}}}s.Nc=o}},s={};function i(t){var r=s[t];if(void 0!==r)return r.exports;var n=s[t]={exports:{}};return e[t](n,n.exports,i),n.exports}(()=>{var e=i(637),s=i(909),t=i(546);const r=window;r.Observable=e.Observable,r.Collector=s.P,r.OrderedObservable=t.Nc})()})();
|