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


TypeScript BehaviorSubject.next方法代碼示例

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


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

示例1: it

    it('depends on both isExecuting and canExecute', (done) => {
      const canExecuteInput = new BehaviorSubject(true);
      const canExecute = new BehaviorSubject(false);
      const cmd = new ReactiveCommand(testOwner, x => {
        canExecute.value.should.be.false;

        return true;
      }, canExecuteInput);


      cmd.canExecute.subscribe(canExecute);

      canExecute.value.should.be.true;

      canExecuteInput.next(false);
      canExecute.value.should.be.false;

      canExecuteInput.next(true);
      canExecute.value.should.be.true;

      cmd.results.subscribe(x => {
        canExecute.value.should.be.true;

        done();
      });

      cmd.execute();
    });
開發者ID:patsissons,項目名稱:rxobj,代碼行數:28,代碼來源:ReactiveCommand.spec.ts

示例2: it

  it('can buffer stream events while paused', () => {
    const source = new Subject();
    const sink = new BehaviorSubject(0);
    let count = 0;
    const pauser = new BehaviorSubject(false);
    source
      .pausableBuffer(pauser)
      .do(() => { ++count; })
      .subscribe(sink);

    sink.value.should.eql(0);

    source.next(1);
    sink.value.should.eql(1);
    count.should.eql(1);

    pauser.next(true);

    source.next(2);
    sink.value.should.eql(1);
    count.should.eql(1);

    source.next(3);
    sink.value.should.eql(1);
    count.should.eql(1);

    pauser.next(false);
    sink.value.should.eql(3);

    count.should.eql(3);
  });
開發者ID:patsissons,項目名稱:rxobj,代碼行數:31,代碼來源:PausableBuffer.spec.ts

示例3: tap

        tap(r => {
          this.dataStore.allNotes.push(r.data);
          this._allNotes.next([...this.dataStore.allNotes]);

          this.dataStore.myNotes.push(r.data);
          this._myNotes.next([...this.dataStore.myNotes]);

          this.downloadContributions();
        }),
開發者ID:a-vzhik,項目名稱:white-raven,代碼行數:9,代碼來源:note.service.ts

示例4:

 .subscribe((value)=>{
   console.log(value);
   this.filters.next({
     ...this.filters.value,
     ...value
   })
 })
開發者ID:darekodz,項目名稱:angular-app,代碼行數:7,代碼來源:search.component.ts

示例5: test

test('re-validate config when updated', async () => {
  const config$ = new BehaviorSubject(new ObjectToConfigAdapter({ key: 'value' }));

  const configService = new ConfigService(config$, defaultEnv, logger);
  configService.setSchema('key', schema.string());

  const valuesReceived: any[] = [];
  await configService.atPath('key').subscribe(
    value => {
      valuesReceived.push(value);
    },
    error => {
      valuesReceived.push(error);
    }
  );

  config$.next(new ObjectToConfigAdapter({ key: 123 }));

  await expect(valuesReceived).toMatchInlineSnapshot(`
Array [
  "value",
  [Error: [key]: expected value of type [string] but got [number]],
]
`);
});
開發者ID:elastic,項目名稱:kibana,代碼行數:25,代碼來源:config_service.test.ts

示例6: it

it("should filter higher order observables", async t => {
    const input = [new BehaviorSubject(3), new BehaviorSubject(4), new BehaviorSubject(5), new BehaviorSubject(6)];
    const origin = new ObservableArray(input);
    const computed = origin.filterx(number$ => number$.pipe(map(n => n % 2 === 0)));
    let output: BehaviorSubject<number>[] = [];
    computed.subscribe(x => output = x);

    t.is(output.length, 2);
    t.deepEqual(output[0], input[1]);

    input[0].next(2);

    t.is(output.length, 3);
    t.deepEqual(output[0], input[0]);

    const o$ = new BehaviorSubject(8);
    origin.unshift(o$);

    t.is(output.length, 4);
    t.deepEqual(output[0], o$);

    o$.next(9);

    t.is(output.length, 3);
    t.deepEqual(output[0], input[0]);
});
開發者ID:milutinovici,項目名稱:proactive,代碼行數:26,代碼來源:computed-array-spec.ts

示例7: resolve

                .subscribe((response: any) => {

                    this.factorData = response;
                    console.log("data get by Id", this.factorData)
                    this.onDataChanged.next(this.factorData);
                    resolve(response);
                }, reject);
開發者ID:,項目名稱:,代碼行數:7,代碼來源:

示例8: setState

	public setState( updater: any ) : void {

		var currentState = this.getSnapshot();
		// If the updater is a function, then it will need the current state in order to
		// generate the next state. Otherwise, the updater is the Partial<T> object.
		// --
		// NOTE: There's no need for try/catch here since the updater() function will
		// fail before the internal state is updated (if it has a bug in it). As such, it
		// will naturally push the error-handling to the calling context, which makes
		// sense for this type of workflow.
		var partialState = ( updater instanceof Function )
			? updater( currentState )
			: updater
		;

		// If the updater function returned undefined, then it decided that no state
		// needed to be changed. In that case, just return-out.
		if ( partialState === undefined ) {

			return;

		}

		var nextState = Object.assign( {}, currentState, partialState );

		this.stateSubject.next( nextState );

	}
開發者ID:bennadel,項目名稱:JavaScript-Demos,代碼行數:28,代碼來源:simple.store.ts

示例9: deselectTodos

    /**
     * Deselect todos
     */
    deselectTodos(): void
    {
        this.selectedTodos = [];

        // Trigger the next event
        this.onSelectedTodosChanged.next(this.selectedTodos);
    }
開發者ID:karthik12ui,項目名稱:fuse-angular-full,代碼行數:10,代碼來源:todo.service.ts


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