當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Observable.range方法代碼示例

本文整理匯總了TypeScript中rxjs/Rx.Observable.range方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Observable.range方法的具體用法?TypeScript Observable.range怎麽用?TypeScript Observable.range使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rxjs/Rx.Observable的用法示例。


在下文中一共展示了Observable.range方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1:

 observable1 = constructorZone1.run(() => {
   return Rx.Observable.range(0, 3)
       .map(function(x: any) {
         return Rx.Observable.range(x, 3);
       })
       .switch ();
 });
開發者ID:jahtalab,項目名稱:zone.js,代碼行數:7,代碼來源:rxjs.Observable.merge.spec.ts

示例2: function

 observable1 = constructorZone1.run(() => {
   return Rx.Observable.forkJoin(
       Rx.Observable.range(1, 2), Rx.Observable.from([4, 5]), function(x, y) {
         expect(Zone.current.name).toEqual(constructorZone1.name);
         return x + y;
       });
 });
開發者ID:jahtalab,項目名稱:zone.js,代碼行數:7,代碼來源:rxjs.forkjoin.spec.ts

示例3: it

 it('should count a range().take(1) source observable', (done: MochaDone) => {
   Rx.Observable.range(1, 10).take(1).count().subscribe(
     (value: number) => {
       expect(value).to.equal(1);
     }, (x) => {
       done(new Error('should not be called'));
     }, () => {
       done();
     });
 });
開發者ID:jayphelps,項目名稱:rxjs,代碼行數:10,代碼來源:count-spec.ts

示例4: second

 .retryWhen((attempts:any) => {
     return Observable
         .range(1, 3)
         .zip(attempts, (i) => { 
             return i; 
         })
         .flatMap( (i) => {
             console.log("Unable to fetch...delay retry by " + i + " second(s)")
             return Observable.timer(i * 1000);
         })
 })
開發者ID:aheinrich,項目名稱:bench-resttest,代碼行數:11,代碼來源:transactions.service.ts

示例5: it

  it('should subscribe to observables that are an instanceof Rx.Observable', (done) => {
    const expected = [1, 2, 3];
    const result = Rx.Observable.range(1, 3);

    const subscriber = new OuterSubscriber<number, number>(x => {
      expect(expected.shift()).to.be.equal(x);
    }, () => {
      done(new Error('should not be called'));
    }, () => {
      expect(expected).to.be.empty;
      done();
    });

    subscribeToResult(subscriber, result);
  });
開發者ID:DallanQ,項目名稱:rxjs,代碼行數:15,代碼來源:subscribeToResult-spec.ts

示例6: constructor

  constructor() {
    this.raw = [];

    this.numberStream = Rx.Observable.range(0,10);

    this.numberStream
      .subscribe(n => this.raw.push(n));

    this.numberStream
      .filter(n => n % 3 === 0)
      .map(n => n * 3)
      .toArray()
      .subscribe(numbers => this.numbers = numbers);

    this.numberStream
      .scan((sum: number, n: number) => sum + n)
      .subscribe((total: number) => this.total = total);


  }
開發者ID:KadoTomohiro,項目名稱:rxChallenge,代碼行數:20,代碼來源:simple.ts

示例7: constructor

    // notify completion of observable.
    constructor() {

        var d1 = Observable.throw(new Error("error"));
        d1.subscribe(
            x => console.log(x),
            err => console.error(err),
            () => console.log("completed")
        );

        var d2 = Observable.range(1,10);
        d2.subscribe(
            x => console.log(x),
            err => console.error(err),
            () => console.log("completed")
        );

        // // own counter
        // var counter = 0;
        // var d3 = Observable
        //     .interval(1000)
        //     .flatMap(x => counter < 10 ? Observable.of(counter++) : Observable.throw("error"));
        // d3.subscribe(
        //     x => console.log(x),
        //     err => console.error(err),
        //     () => console.log("completed")
        // );

        var c = 0;
        var d4 = Observable
            .interval(1000)
            .take(10)
            .map(x => c++);
        d4.subscribe(
            x => console.log(x),
            err => console.error(err),
            () => console.log("completed")
        );
                
    }
開發者ID:kwanling,項目名稱:ng2test,代碼行數:40,代碼來源:app3.component.ts

示例8:

            let generateRequests = (numberOfRequests: number) => {
                let requestStream = Observable
                    .range(startingPage + 1, numberOfRequests - 1)
                    .flatMap(pageNumber => {
                        return this.getPageRequest(pageNumber);
                    })

                requestStream.subscribe(
                    // On Value
                    (benchData: IBenchData) => {
                        results.next(benchData.transactions)
                    },
                    // On Error
                    (error: any) => {
                        console.log("Unable to execute request for additional remote resources")
                        results.error(error)
                    },
                    // On Complete
                    () => {
                        results.complete()
                    })
            }
開發者ID:aheinrich,項目名稱:bench-resttest,代碼行數:22,代碼來源:transactions.service.ts

示例9: constructor3

    constructor3() {
        console.log(new Observable());
        
        var d1 = Observable.empty();
        d1.subscribe(x => console.log(x));

        var d2 = Observable.range(1, 5);
        d2.subscribe(x => console.log(x));

        var d3 = Observable.fromArray([1,2,3]);
        d3.subscribe(x => console.log(x));

        var d4 = Observable.of(1);
        d4.subscribe(x => console.log(x));

        var d5 = Observable.of(1,2,3);
        d5.subscribe(x => console.log(x));

        var d6 = Observable.of([1,2,3]);
        d6.subscribe(x => console.log(x));
                
    }
開發者ID:kwanling,項目名稱:ng2test,代碼行數:22,代碼來源:app3.component.ts

示例10:

 observable2 = constructorZone2.run(() => {
   return Rx.Observable.range(3, 4);
 });
開發者ID:jahtalab,項目名稱:zone.js,代碼行數:3,代碼來源:rxjs.Observable.concat.spec.ts


注:本文中的rxjs/Rx.Observable.range方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。