ngOnInit() { // load the initial bank list this.filteredBanks.next(this.banks.slice()); // listen for search field value changes this.bankFilterCtrl.valueChanges .pipe(takeUntil(this._onDestroy)) .subscribe(() => { this.filterBanks(); }); }
useEffect(() => { this.stream .pipe(map(selector), takeUntil(unsubscribe$)) .subscribe(setValue); return () => { unsubscribe$.next(); unsubscribe$.complete(); }; // eslint-disable-next-line react-hooks/exhaustive-deps }, []);
@HostListener('mousedown', ['$event']) onMouseDown(event: MouseEvent) { this.mouseStart = {x: event.pageX, y: event.pageY}; const mouseup$ = Observable.fromEvent(document, 'mouseup'); this._subscription = mouseup$.subscribe(() => this.onMouseup()); const mousemove$ = Observable.fromEvent(document, 'mousemove') .pipe(takeUntil(mouseup$)) .subscribe((e: MouseEvent) => this.onMouseMove(e)); this._subscription.add(mousemove$); }
const actionOfType = (actionId, cancelId) => (action$) => { return action$.pipe( tap(val => console.log("epic val: "+ JSON.stringify(val) )), ofType(actionId), debounce(() => interval(500)), takeUntil( action$.pipe( filter(action => action.type === cancelId), ))); }
private loadDevices() { // load the initial variable list this.filteredDevice.next(this.data.devices.slice()); // listen for search field value changes this.deviceFilterCtrl.valueChanges .pipe(takeUntil(this._onDestroy)) .subscribe(() => { this.filterDevice(); }); }
const fetchGetAmiiboEpic = (action$, state$, { schema }) => action$.pipe( ofType(FETCH_GET_AMIIBO_LIST), debounceTime(500), switchMap(action => getApi(action.payload, 'fetchGetAmiiboList') .pipe( flatMap((response) => { const { entities } = normalize(response.data.amiibo, schema.amiiboList) return [ fetchGetAmiiboListSuccess(response.data), addAmiiboListEntities(entities), ] }), catchError(error => of(fetchGetAmiiboListFailure(error))), )), takeUntil(action$.pipe(ofType(FETCH_GET_AMIIBO_LIST_CANCEL))), repeat(), )
_run(cb) { this.done = cb; const self = this; const events = observe(this.rl); events.normalizedUpKey.pipe(takeUntil(events.line)) .forEach(this.onUpKey.bind(this)); events.normalizedDownKey.pipe(takeUntil(events.line)) .forEach(this.onDownKey.bind(this)); events.line.pipe( take(1), map(this.getCurrentValue.bind(this)), flatMap(value => runAsync(self.opt.filter)(value).catch(err => err)) ) .forEach(this.onSubmit.bind(this)); cliCursor.hide(); this.render(); return this; }
/** * Sets the overlay class to correct offsetY * so that the selected option is at the position of the select box when opening */ private setOverlayClass() { if (this.overlayClassSet) { return; } const overlayClass = 'cdk-overlay-pane-select-search'; this.matSelect.overlayDir.attach .pipe(takeUntil(this._onDestroy)) .subscribe(() => { // note: this is hacky, but currently there is no better way to do this this.searchSelectInput.nativeElement.parentElement.parentElement .parentElement.parentElement.parentElement.classList.add(overlayClass); }); this.overlayClassSet = true; }
constructor(sink = null, stream = null, name = "bloc") { this.unsubscribe$ = new Subject(); this.sink = sink || new Subject(); this.stream = stream || new BehaviorSubject(this.state).pipe( // rxjs debug tag(`${name}.bloc`) ); this.initActions(); this.sink.pipe(takeUntil(this.unsubscribe$)).subscribe(action => { if (action && action.type && this.actions[action.type]) { this.state = this.actions[action.type](action.payload); this.stream.next(this.state); } }); }
private startPolling() { try { if (!this.alarmsPolling) { this.alarmsPolling = 1; this.destroy = new Subject(); this.rxjsPollingTimer.pipe(takeUntil(this.destroy), switchMap(() => this.hmiService.getAlarmsValues().pipe( catchError((er) => this.handleError(er))) )).subscribe(result => { this.updateAlarmsList(result); }); } } catch (error) { } }
private loadAlarm(toset?: string) { // load the initial variable list this.filteredAlarm.next(this.alarme.slice()); // listen for search field value changes this.alarmFilterCtrl.valueChanges .pipe(takeUntil(this._onDestroy)) .subscribe(() => { this.filterAlarm(); }); if (toset) { let idx = -1; this.alarme.every(function(value, index, _arr) { if (value.id === toset) { idx = index; return false; } return true; }); if (idx >= 0) { this.alarmCtrl.setValue(this.alarme[idx]); } } }
private loadAlarmDevices() { // load the initial variable list this.filteredAlarmDevice.next(this.data.devices.slice()); // listen for search field value changes this.alarmDeviceFilterCtrl.valueChanges .pipe(takeUntil(this._onDestroy)) .subscribe(() => { this.filterAlarmDevice(); }); }
private loadVariable(toset?: string) { // load the initial variable list this.filteredVariable.next(this.variableList.slice()); // listen for search field value changes this.variableFilterCtrl.valueChanges .pipe(takeUntil(this._onDestroy)) .subscribe(() => { this.filterVariable(); }); if (toset) { let idx = -1; this.variableList.every(function (value, index, _arr) { if (value.id === toset) { idx = index; return false; } return true; }); if (idx >= 0) { this.variableCtrl.setValue(this.variableList[idx]); } } }
private loadDevices() { // load the initial variable list this.filteredDevice.next(this.data.devices.slice()); // listen for search field value changes this.deviceFilterCtrl.valueChanges .pipe(takeUntil(this._onDestroy)) .subscribe(() => { this.filterDevice(); }); }
useEffect(() => { this.stream .pipe(map(selector), takeUntil(unsubscribe$)) .subscribe(setValue); return () => { unsubscribe$.next(); unsubscribe$.complete(); }; // eslint-disable-next-line react-hooks/exhaustive-deps }, []);