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


TypeScript Observable.merge方法代码示例

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


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

示例1: test

 test('new game', function() {
   expect(model(O.merge(
     O.of({type: 'ROLL', payload: 1}),
     O.of({type: 'NEW GAME'})
   ), mockProps$).skip(1).first()).toBeStreamOf(
     ['1', [1], true, false, mockProps]
   );
   expect(model(O.merge(
     O.of({type: 'ROLL', payload: 1}),
     O.of({type: 'NEW GAME'})
   ), mockProps$).last()).toBeStreamOf(
     ['', [], true, false, mockProps]
   );
 });
开发者ID:wizardwerdna,项目名称:FRPBowlingKata,代码行数:14,代码来源:model.spec.ts

示例2: constructor

    constructor() {
        this.toggleLeftPane = new Rx.Subject<boolean>();

        this.focusInputBox = new Rx.Subject<void>();
        this.focusWindow = new Rx.Subject<void>();

        this.selectChannel = new Rx.Subject<ChannelId>();

        this.setQuitConfirmDialog = new Rx.Subject<void>();

        this.showConnectSetting = new Rx.Subject<void>();
        this.showGeneralSetting = new Rx.Subject<void>();

        this.showSignIn = new Rx.Subject<void>();

        this.showLatestInChannel = new Rx.Subject<ChannelId>();
        this.tryCloseChannel = new Rx.Subject<ChannelId>();
        this.toggleInlineImage = new Rx.Subject<void>();

        this.showSomeSettings = Rx.Observable.merge<SettingId, SettingId>(...[
            this.showSignIn.map(function() { return 'sign-in'; }),
            this.showConnectSetting.map(function() { return 'connect'; }),
            this.showGeneralSetting.map(function() { return 'settings'; }),
        ]);
    }
开发者ID:saneyuki,项目名称:karen,代码行数:25,代码来源:UIActionDispatcher.ts

示例3: it

    it('should hide responses from outside the scope', function(done) {
      const proxyRequest$ = new Rx.Subject();
      function main(sources: {HTTP: HTTPSource}) {
        return {
          HTTP: proxyRequest$,
        };
      }

      const {sources, run} = Cycle.setup(main, {HTTP: makeHTTPDriver()});

      const ignoredRequest$ = Rx.Observable.of(uri + '/json');
      const request$ = Rx.Observable.of(uri + '/hello').delay(10);
      const scopedRequest$ = sources.HTTP.isolateSink(request$, 'foo');
      const scopedHTTPSource = sources.HTTP.isolateSource(sources.HTTP, 'foo');

      scopedHTTPSource.select().subscribe(function(response$) {
        assert.strictEqual(typeof response$.request, 'object');
        assert.strictEqual(response$.request.url, uri + '/hello');
        response$.subscribe(function(response) {
          assert.strictEqual(response.status, 200);
          assert.strictEqual(response.text, 'Hello World');
          done();
        });
      });

      Rx.Observable
        .merge(ignoredRequest$, scopedRequest$)
        .subscribe(proxyRequest$);

      run();
    });
开发者ID:nlarche,项目名称:cyclejs,代码行数:31,代码来源:common.ts

示例4: it

    it('should remove old paths', () => {
        const data = ['a', 'b', 'c'];
        const data2 = ['a', 'b'];
        let callback: (paths: string[]) => void;
        const tracker = new ProjectTracker({
            getPaths() { return data; },
            onDidChangePaths(cb) {
                callback = cb;
                return { dispose() { /* */ } };
            }
        });

        return Observable.merge(
            tracker.removed
                .take(1),
            tracker.added
                .take(3)
                .subscribeOn(Scheduler.async)
                .do({
                    complete() {
                        callback(data2);
                    }
                })
        )
            .take(4)
            .toArray()
            .toPromise()
            .then(values => {
                expect(values).to.deep.eq(['a', 'b', 'c', 'c']);
            });
    });
开发者ID:OmniSharp,项目名称:atom-languageclient,代码行数:31,代码来源:ProjectTrackerSpec.ts

示例5: disconnected

 disconnected(): Rx.Observable<void> {
     const args = [
         this._socket.connectError(),
         this._socket.disconnect(),
     ];
     return Rx.Observable.merge<void, void>(...args);
 }
开发者ID:saneyuki,项目名称:karen,代码行数:7,代码来源:MessageGateway.ts

示例6: main

function main({DOM}) {
  const username$ = DOM.select('#username').events('input');
  const password$ = DOM.select('#password').events('input');
  const loginButton$ = DOM.select('#login').events('click');
  const form$ = O.combineLatest(
    username$.map(e => e.target.value),
    password$.map(e => e.target.value),
    (username, password) => ({username, password})
  );
  const action$: O<any> = O.merge(
    form$.map( formData => loginButton$.mapTo((
      { type: 'LOGIN', payload: formData }
    ))).switch()
  ).distinctUntilChanged();

  const reducer$ = O.merge(
    action$
      .filter((action) => action.type === 'LOGIN')
      .map(action => function loginReducer(state) {
        return state +
          `$$$ login(${action.payload.username}, ${action.payload.password})`;
      })
  );

  const state$ = reducer$.scan((state, next) => next(state), '')
    .startWith('');

  return {DOM: state$.map(state =>
    div('.container', {props: {style: 'margin: 1pc'}}, [
      div(state),
      div('.form', {props: {style: 'outline: 1pt solid blue; padding: 1pc'}}, [
        div('.form-group', [
          label({props: {for: 'username'}}, 'Username'),
          input('#username.form-control', {props: {type: 'text', autofocus: true}}),
        ]),
        div('form-group', [
          label({props: {for: 'password'}}, 'Password'),
          input('#password.form-control', {props: {type: 'password'}}),
        ]),
        hr(),
        div('.form-group', [
          button('#login.form-control.btn.btn-primary', 'Log In')
        ])
      ])
    ])
  )};
}
开发者ID:wizardwerdna,项目名称:CycleSimpleFormExample,代码行数:47,代码来源:app.ts

示例7: it

	it('deve executar multiplas operaçþes assincronas em conjunto', done => {
		Observable.merge<number>(operacaoAssincrona(10), operacaoAssincrona(20))
			.filter(response => !!(response % 2))
			.toArray()
			.subscribe(response => {
				expect(response).to.deep.equal([1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]);
			}, null, done);
	});
开发者ID:feliperohdee,项目名称:node-meetup-cheatsheet,代码行数:8,代码来源:observables.ts

示例8: subscribeUsers

  subscribeUsers(): Subscription {
    // Fetch all users matching search pattern
    const subscription = MeteorObservable.subscribe('users', this.searchPattern.getValue());
    const autorun = MeteorObservable.autorun();

    return Observable.merge(subscription, autorun).subscribe(() => {
      this.users = this.findUsers();
    });
  }
开发者ID:ShinFDuran,项目名称:Pruebas,代码行数:9,代码来源:new-chat.ts


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