English 中文(简体)
从可观测到的安热服务回包
原标题:Angular Service return boolean from Observable
  • 时间:2024-05-10 23:13:30
  •  标签:
  • angular

总体情况是,我不想让消费者做rib子/un子。 我希望他们叫SapBooleanFeature Toggle(toggleKey:string)并返回羊毛。

  getBooleanFeatureToggleAsObservable(toggleKey: string): Observable<boolean> {
    return from(this.getBooleanFeatureToggleAsPromise(toggleKey));
  }

  public async getMyFlag(toggleKey: string): Promise<boolean> {
    let flag = false;
    const sub = await this.getBooleanFeatureToggleAsObservable(toggleKey).subscribe({

        next: (featureEnabled: boolean) => {
            console.log( featureEnabled , featureEnabled);
            flag = featureEnabled;
        },
        error: (error: any) => console.error(error)
    });

    return flag;
}

  public getBooleanFeatureToggle(toggleKey: string) {
    const myFlag = this.getMyFlag(toggleKey);
    console.log( myFlag , myFlag);
    return false;
  }
问题回答

仅仅等待着这一承诺,为什么哪怕是站不住脚的,因为你们不想接受这一承诺!

 getBooleanFeatureToggleAsObservable(toggleKey: string): any {
    return this.getBooleanFeatureToggleAsPromise(toggleKey);
  }

  public async getMyFlag(toggleKey: string): boolean {
    const flag = await this.getBooleanFeatureToggleAsObservable(toggleKey);
    return flag;
}

  public getBooleanFeatureToggle(toggleKey: string) {
    const myFlag = this.getMyFlag(toggleKey);
    console.log( myFlag , myFlag);
    return false;
  }




相关问题
Angular matSort not working on Date column by desc

Trying to sort the material table with date column , date format is MM/DD/YYYY ,h:mm A , order of date is not by latest date and time. Anything which i missed from the below stackblitz code. https:/...

热门标签