随笔分类 - RxJS
摘要:Converts an observable to a promise by subscribing to the observable, and returning a promise that will resolve as soon as the first value arrives fro
阅读全文
摘要:class Observable { constructor(subscribe) { this._subscribe = subscribe; } subscribe(observer) { return this._subscribe(observer); } static of(value)
阅读全文
摘要:class Observable { constructor(subscribe) { this._subscribe = subscribe; } subscribe(observer) { return this._subscribe(observer); } static concnat(..
阅读全文
摘要:const tasks = of([....]); /** * { * ...{ ...4......5......2} * ...........{3...........2...5} * ..................................{6.... 3} * ........
阅读全文
摘要:import { interval, fromEvent, of, merge, empty } from 'rxjs'; import { scan, mapTo, takeWhile, takeUntil, tap, startWith, switchMap } from 'rxjs/opera
阅读全文
摘要:// begin lesson code import { interval, fromEvent, of } from 'rxjs'; import { scan, mapTo, takeWhile, takeUntil, tap, startWith, endWith } from 'rxjs/
阅读全文
摘要:// begin lesson code import { fromEvent, partition } from 'rxjs'; import { filter, pluck } from 'rxjs/operators'; const MOVE_SPEED = 20; let leftPosit
阅读全文
摘要:const onDestroy$ = new Subject(); fromEvent(document, 'click').pipe( map((event: any) => ({ x: event.clientX, y: event.clientY })), takeUntil(onDestro
阅读全文
摘要:/* * From */ click$.pipe( mergeMapTo(throwError({ status: 400, message: 'Server error' }).pipe( retryWhen(attempts => { return attempts.pipe( mergeMap
阅读全文
摘要:catchError will complete the observable, so be careful where you put the catchError: import { fromEvent, empty } from 'rxjs'; import { ajax } from 'rx
阅读全文
摘要:Maps values to a new observable on emission from source, subscribing to and emitting results of inner observables By default mergeMap does not limit t
阅读全文
摘要:const input$ = fromEvent(textInput, 'keyup'); input$.pipe( map(event => { const term = event.target.value; return ajax.getJSON(`https://api.github.com
阅读全文
摘要:Calling .unsubscribe()will NOT trigger completecallback! const sub = interval(1000).subscribe({ next: (val: any) => { counter.innerHTML = val; }, comp
阅读全文
摘要:const { of } = require("rxjs"); const { mergeMap, map, delay, catchError } = require("rxjs/operators"); describe("subscribe & assert testing in RxJS",
阅读全文
摘要:For example we have a search input: const input$ = fromEvent(document.getElementById("#input"), "input"); input$ .pipe( debounceTime(200), pluck("targ
阅读全文
摘要:const { TestScheduler } = require("rxjs/testing"); const { map, take, delay, mapTo, catchError } = require("rxjs/operators"); const { concat, from, of
阅读全文
摘要:describe("Marble testing in Rxjs", () => { let testScheduler; beforeEach(() => { testScheduler = new TestScheduler((actual, expected) => { expect(actu
阅读全文
摘要:const { TestScheduler } = require("rxjs/testing"); const { map, take, delay, mapTo, catchError } = require("rxjs/operators"); const { concat, from, of
阅读全文
摘要:auditTime: import { fromEvent } from 'rxjs'; import { auditTime, map } from 'rxjs/operators'; const click$ = fromEvent(document, 'click'); click$ .pip
阅读全文
摘要:SampleTime If there is no value emiited between sample time and previous emited value, ouput won't have anything. import { fromEvent, interval } from
阅读全文