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


TypeScript BehaviorSubject.getValue方法代码示例

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


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

示例1: setInitialAudioTrack

  /**
   * Emit initial audio Adaptation through the given Subject based on:
   *   - the preferred audio tracks
   *   - the last choice for this period, if one
   * @param {Period} period
   *
   * @throws Error - Throws if the period given has not been added
   */
  public setInitialAudioTrack(period : Period) : void {
    const periodItem = getPeriodItem(this._periods, period);
    const audioInfos = periodItem && periodItem.audio;
    if (!audioInfos || !periodItem) {
      throw new Error("TrackManager: Given Period not found.");
    }

    const preferredAudioTracks = this._preferredAudioTracks.getValue();
    const audioAdaptations = period.adaptations.audio || [];
    const chosenAudioAdaptation = this._audioChoiceMemory.get(period);

    if (
      chosenAudioAdaptation === undefined ||
      !arrayIncludes(audioAdaptations, chosenAudioAdaptation)
    ) {
      const normalizedTracks = normalizeAudioTracks(preferredAudioTracks);
      const optimalAdaptation =
        findFirstOptimalAudioAdaptation(audioAdaptations, normalizedTracks);

      this._audioChoiceMemory.set(period, optimalAdaptation);
      audioInfos.adaptation$.next(optimalAdaptation);
    } else {
      audioInfos.adaptation$.next(chosenAudioAdaptation);
    }
  }
开发者ID:canalplus,项目名称:rx-player,代码行数:33,代码来源:track_manager.ts

示例2: it

it("for: bind to a value yielding an array", async (t) => {
    const template = `<ul><li x-for:item.i="src" x-text="i"></li></ul>`;
    const el = parse(template)[0] as HTMLElement;

    const prop = new BehaviorSubject<number[]>([]);

    t.notThrows(() => ui.domManager.applyDirectives({ src: prop }, el));
    t.is(el.children.length, prop.getValue().length);
    t.deepEqual(toArray(el.children).map((node) => parseInt(node.textContent || "")), range(0, prop.getValue().length));

    const array = [1, 5, 7];
    prop.next(array);
    t.is(el.children.length, prop.getValue().length);
    t.deepEqual(toArray(el.children).map((node) => parseInt(node.textContent || "")), range(0, prop.getValue().length));

});
开发者ID:milutinovici,项目名称:proactive,代码行数:16,代码来源:for-spec.ts

示例3: 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

示例4: setFavourite

 public async setFavourite(person: PersonDTO, isFavourite: boolean): Promise<void> {
   const updated = await this.networkService.postJson<PersonDTO>('/person/' + person.name, {isFavourite: isFavourite});
   const updatesList = this.persons.getValue();
   for (let i = 0; i < updatesList.length; i++) {
     if (updatesList[i].id === updated.id) {
       updatesList[i] = updated;
       this.persons.next(updatesList);
       return;
     }
   }
 }
开发者ID:bpatrik,项目名称:PiGallery2,代码行数:11,代码来源:faces.service.ts

示例5: it

it("value: Should update observable properties on the model when the radio's click event fires", async (t) => {
    const template = `<input type="radio" x-value="someProp" value="my"/>`;
    const element = parse(template)[0] as HTMLInputElement;

    const myobservable = new BehaviorSubject("other");
    ui.domManager.applyDirectives({ someProp: myobservable }, element);

    triggerEvent(element, "click");
    t.is(myobservable.getValue(), "my");

});
开发者ID:milutinovici,项目名称:proactive,代码行数:11,代码来源:checked-spec.ts

示例6: it

it("value: input values type should be consistent", async (t) => {
    const template = `<input type="number" x-value="someProp" />`;
    const number = new BehaviorSubject(0);
    const el = parse(template)[0] as HTMLInputElement;
    const viewmodel = { someProp: number };
    ui.domManager.applyDirectives(viewmodel, el);

    el.value = "3";
    triggerEvent(el, "change");
    t.is(4, 1 + number.getValue());

});
开发者ID:milutinovici,项目名称:proactive,代码行数:12,代码来源:value-spec.ts

示例7: _updateTextTrackChoices

  private _updateTextTrackChoices() {
    const preferredTextTracks = this._preferredTextTracks.getValue();
    const normalizedTracks = normalizeTextTracks(preferredTextTracks);

    const recursiveUpdateTextTrack = (index : number) : void => {
      if (index >= this._periods.length()) {
        // we did all text Buffers, exit
        return;
      }

      const periodItem = this._periods.get(index);
      if (periodItem.text == null) {
        // No text Buffer for this period, check next one
        recursiveUpdateTextTrack(index + 1);
        return;
      }

      const {
        period,
        text: textItem,
      } = periodItem;
      const textAdaptations = period.adaptations.text || [];
      const chosenTextAdaptation = this._textChoiceMemory.get(period);

      if (
        chosenTextAdaptation === null ||
        (
          chosenTextAdaptation !== undefined &&
          arrayIncludes(textAdaptations, chosenTextAdaptation)
        )
      ) {
        // Already best text for this Buffer, check next one
        recursiveUpdateTextTrack(index + 1);
        return;
      }

      const optimalAdaptation =
        findFirstOptimalTextAdaptation(textAdaptations, normalizedTracks);

      this._textChoiceMemory.set(period, optimalAdaptation);
      textItem.adaptation$.next(optimalAdaptation);

      // previous "next" call could have changed everything, start over
      recursiveUpdateTextTrack(0);
    };

    recursiveUpdateTextTrack(0);
  }
开发者ID:canalplus,项目名称:rx-player,代码行数:48,代码来源:track_manager.ts

示例8: actorsInit

    .switchMap(event => {
      startButton.value = 'RESTART';
      pauseButton.disabled = false;
      const game = gameState$$.getValue();
      pauseButton.disabled = false;

      if (game.firstRun) {
        game.firstRun = false;
      } else {
        game.actors = actorsInit();
        game.paused = true;
        game.gameOver = false;
      }

      const gameOver$ = gameState$$.pluck('gameOver').distinct().filter(gameOver => gameOver===true);
      const pauseClick$ = Observable.fromEvent(pauseButton, 'click')
      return Observable.merge(gameOver$, pauseClick$)
        .startWith('whatever')
        .switchMap(event => {
          switch(true) {
            case event===true:
              pauseButton.value = 'GAME OVER';
              pauseButton.disabled = true;
              return Observable.of(game)
            default:
              game.paused = !game.paused;
              switch (game.paused) {
                case true:
                  pauseButton.value = 'CONTINUE';
                  return Observable.of(game);
                case false:
                  pauseButton.value = 'PAUSE';
                  return onContinue$Fac(game);
              }
          }
        })
    })
开发者ID:timathon,项目名称:rx-space,代码行数:37,代码来源:shared.ts

示例9: getDevices

 getDevices(): Device[] {
     return this._loadedDevices.getValue();
 }
开发者ID:justaniles,项目名称:smart-home-portal,代码行数:3,代码来源:device.service.ts


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