当前位置: 首页>>代码示例>>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;未经允许,请勿转载。