當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。