随笔分类 -  RxJS

1 2 3 4 5 ··· 11 下一页
摘要: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 阅读全文
posted @ 2024-02-11 22:00 Zhentiw 阅读(167) 评论(0) 推荐(0)
摘要:class Observable { constructor(subscribe) { this._subscribe = subscribe; } subscribe(observer) { return this._subscribe(observer); } static of(value) 阅读全文
posted @ 2023-09-12 16:04 Zhentiw 阅读(7) 评论(0) 推荐(0)
摘要:class Observable { constructor(subscribe) { this._subscribe = subscribe; } subscribe(observer) { return this._subscribe(observer); } static concnat(.. 阅读全文
posted @ 2023-09-12 15:44 Zhentiw 阅读(10) 评论(0) 推荐(0)
摘要:const tasks = of([....]); /** * { * ...{ ...4......5......2} * ...........{3...........2...5} * ..................................{6.... 3} * ........ 阅读全文
posted @ 2023-09-08 15:39 Zhentiw 阅读(6) 评论(0) 推荐(0)
摘要:import { interval, fromEvent, of, merge, empty } from 'rxjs'; import { scan, mapTo, takeWhile, takeUntil, tap, startWith, switchMap } from 'rxjs/opera 阅读全文
posted @ 2022-10-26 14:23 Zhentiw 阅读(30) 评论(0) 推荐(0)
摘要:// begin lesson code import { interval, fromEvent, of } from 'rxjs'; import { scan, mapTo, takeWhile, takeUntil, tap, startWith, endWith } from 'rxjs/ 阅读全文
posted @ 2022-10-22 16:43 Zhentiw 阅读(28) 评论(0) 推荐(0)
摘要:// begin lesson code import { fromEvent, partition } from 'rxjs'; import { filter, pluck } from 'rxjs/operators'; const MOVE_SPEED = 20; let leftPosit 阅读全文
posted @ 2022-10-22 16:31 Zhentiw 阅读(51) 评论(0) 推荐(0)
摘要:const onDestroy$ = new Subject(); fromEvent(document, 'click').pipe( map((event: any) => ({ x: event.clientX, y: event.clientY })), takeUntil(onDestro 阅读全文
posted @ 2022-10-22 16:20 Zhentiw 阅读(27) 评论(0) 推荐(0)
摘要:/* * From */ click$.pipe( mergeMapTo(throwError({ status: 400, message: 'Server error' }).pipe( retryWhen(attempts => { return attempts.pipe( mergeMap 阅读全文
posted @ 2022-10-22 16:13 Zhentiw 阅读(20) 评论(0) 推荐(0)
摘要:catchError will complete the observable, so be careful where you put the catchError: import { fromEvent, empty } from 'rxjs'; import { ajax } from 'rx 阅读全文
posted @ 2022-10-20 14:43 Zhentiw 阅读(126) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2022-10-19 15:13 Zhentiw 阅读(148) 评论(0) 推荐(0)
摘要:const input$ = fromEvent(textInput, 'keyup'); input$.pipe( map(event => { const term = event.target.value; return ajax.getJSON(`https://api.github.com 阅读全文
posted @ 2022-10-18 21:17 Zhentiw 阅读(43) 评论(0) 推荐(0)
摘要:Calling .unsubscribe()will NOT trigger completecallback! const sub = interval(1000).subscribe({ next: (val: any) => { counter.innerHTML = val; }, comp 阅读全文
posted @ 2022-10-18 21:09 Zhentiw 阅读(42) 评论(0) 推荐(0)
摘要:const { of } = require("rxjs"); const { mergeMap, map, delay, catchError } = require("rxjs/operators"); describe("subscribe & assert testing in RxJS", 阅读全文
posted @ 2022-10-17 14:12 Zhentiw 阅读(28) 评论(0) 推荐(0)
摘要:For example we have a search input: const input$ = fromEvent(document.getElementById("#input"), "input"); input$ .pipe( debounceTime(200), pluck("targ 阅读全文
posted @ 2022-10-14 20:56 Zhentiw 阅读(81) 评论(0) 推荐(0)
摘要:const { TestScheduler } = require("rxjs/testing"); const { map, take, delay, mapTo, catchError } = require("rxjs/operators"); const { concat, from, of 阅读全文
posted @ 2022-10-14 20:24 Zhentiw 阅读(42) 评论(0) 推荐(0)
摘要:describe("Marble testing in Rxjs", () => { let testScheduler; beforeEach(() => { testScheduler = new TestScheduler((actual, expected) => { expect(actu 阅读全文
posted @ 2022-10-14 20:20 Zhentiw 阅读(17) 评论(0) 推荐(0)
摘要:const { TestScheduler } = require("rxjs/testing"); const { map, take, delay, mapTo, catchError } = require("rxjs/operators"); const { concat, from, of 阅读全文
posted @ 2022-10-14 19:35 Zhentiw 阅读(31) 评论(0) 推荐(0)
摘要:auditTime: import { fromEvent } from 'rxjs'; import { auditTime, map } from 'rxjs/operators'; const click$ = fromEvent(document, 'click'); click$ .pip 阅读全文
posted @ 2022-10-13 22:00 Zhentiw 阅读(80) 评论(0) 推荐(0)
摘要:SampleTime If there is no value emiited between sample time and previous emited value, ouput won't have anything. import { fromEvent, interval } from 阅读全文
posted @ 2022-10-13 21:54 Zhentiw 阅读(37) 评论(0) 推荐(0)

1 2 3 4 5 ··· 11 下一页