Big picture is I want the service to return a boolean as I don’t want the consumer to have to do the subscribing/unsubscribing. I want them to call getBooleanFeatureToggle(toggleKey: string) and return the boolean.
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 await flag;
}
public getBooleanFeatureToggle(toggleKey: string) {
const myFlag = this.getMyFlag(toggleKey);
console.log('myFlag', myFlag);
return false;
}