当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Observable.range方法代码示例

本文整理汇总了TypeScript中rxjs.Observable.range方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Observable.range方法的具体用法?TypeScript Observable.range怎么用?TypeScript Observable.range使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rxjs.Observable的用法示例。


在下文中一共展示了Observable.range方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

  it('should not work after has been disposed', function(done) {
    let number$ = Rx.Observable
      .range(1, 3)
      .concatMap(x => Rx.Observable.of(x).delay(150));

    function app(sources: any): any {
      return {other: number$};
    }

    let {sources, run} = setup(app, {
      other: (num$: any) => Observable.from(num$).map((num: any) => 'x' + num),
    });

    let dispose: any;
    sources.other.subscribe(function(x: any) {
      assert.notStrictEqual(x, 'x3');
      if (x === 'x2') {
        dispose();
        setTimeout(() => {
          done();
        }, 100);
      }
    });
    dispose = run();
  });
开发者ID:joeldentici,项目名称:cyclejs,代码行数:25,代码来源:index.ts

示例2: callback

 return source.retryWhen(errors => {
     return Observable
         .zip(Observable.range(1, backoffRetries), errors, (i, e) => [i, e])
         .do(data => callback(data[1]))
         .flatMap(data => Observable.timer(data[0] * data[0] * backoffInterval))
         .concat(Observable
             .timer(pollingInterval, pollingInterval)
             .zip(errors, (timer, error) => error)
             .do(error => callback(error)));
 });
开发者ID:tierratelematics,项目名称:prettygoat,代码行数:10,代码来源:TypesUtil.ts

示例3:

const starsInit$Fac = (stars: iStar[]): Observable<iStar[]> => {
  if (stars.length === 0) { // at START_CLICKED, generate a starsInit$
    return Observable.range(1, config.stars.count)
      .map(item => {
        const size = 1 + Math.random() * 1.5;
        const speed = size > 1.6 ? 0.25 : 0.05;
        const color = '#ffffff'; // whilte
        return {
          x: Math.random() * config.canvas.width,
          y: Math.random() * config.canvas.height,
          size: size,
          speed: speed,
          color: color
        }
      })
      .toArray()
  }
  if (stars.length > 0) { // at CONTINUE_CLICKED, use the stars in the game state
    return Observable.of(stars);
  }
}
开发者ID:timathon,项目名称:rx-space,代码行数:21,代码来源:stars.ts

示例4: Date

 streamFactory.setup(s => s.from(It.isAny(), It.isAny(), It.isAny())).returns(_ => Observable.range(1, 5).map(n => {
     return {type: "increment", payload: n, timestamp: new Date()};
 }));
开发者ID:tierratelematics,项目名称:prettygoat,代码行数:3,代码来源:ProjectionRunnerSpec.ts

示例5: Number

import {Observable} from 'rxjs';
import constants from '../constants/index';
import StarSky from './starsky';

export const StarStream = Observable.range(1,constants.STAR_NUMBER)
  .map(() =>({
    x: Number(Math.random() * StarSky.canvas.width),
    y: Number(Math.random() * StarSky.canvas.height),
    size: Math.random() * 3 + 1
  }))
  .toArray()
  .flatMap(starArray => {
    return Observable.interval(constants.SPEED)
      .map(() => {
        starArray.forEach(star => {
          if(star.y >= StarSky.canvas.height) {
            star.y = 0;
          }
          star.y += 3;
        })
        return starArray;
      });
  });
开发者ID:graforlock,项目名称:spaceship-game,代码行数:23,代码来源:starstream.ts

示例6:

import { Observable } from "rxjs";

const smallNumbers$ =
    Observable.interval(500)
        .take(5);

const largeNumbers$ = Observable.range(101, 10);

const numberRange$ = smallNumbers$.concat(largeNumbers$);

const even$ = numberRange$.filter(num => (num % 2 == 0));

even$.subscribe(num => console.log(num));
开发者ID:Meligy,项目名称:rxjs-samples,代码行数:13,代码来源:07-operators.ts

示例7:

import { Observable } from "rxjs"

// create an observable sequence of 5 integers, starting from 1
var source = Observable.range(1, 5);

// Prints out each item
var subscription = source.subscribe(
    x => console.log('onNext: %s', x),
    e => console.log('onError: %s', e),
    () => console.log('onCompleted'));
开发者ID:JasonGoemaat,项目名称:webpack-test,代码行数:10,代码来源:rxtest.ts


注:本文中的rxjs.Observable.range方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。