[RxJS] Filtering Operator:single, race

Source: Internet
Author: User
Tags emit

Single, race both get only one emit value from the stream.

Single (FN):

Const Source = Rx.Observable.from ([1,2,3,4,5]); var single = Source.single (x = = = = 3); /* (12345) |                   (source) Single (x = = = = 3) 3|                         (single) */ var sub = single.subscribe (x =  //  3

Race (... observable): observable

Const WINNER =Rx.Observable.race (//emit every 1.5sRx.Observable.interval (1500),  //emit every 1sRx.Observable.interval (+) mapto (' 1s won! '),  //emit every 2sRx.Observable.interval (2000),  //emit every 2.5sRx.Observable.interval (2500). Take (1);/**------0 (Mapto)----0 (1s won! ')          --------0 (a)----------0 (2500) race----(1s won!) | (Take (1))*/Const SUB2= Winner.subscribe (x = Console.log (x));//1s won!

[RxJS] Filtering Operator:single, race

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.