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