Created
May 26, 2019 12:27
-
-
Save Gbuomprisco/c7dbd539887fe0a391f6576f82a0d7e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Injectable() | |
export class PricesFacadeServiceImpl implements PricesFacadeService { | |
subscribedAssets$: Observable<string[]> = this.store.select( | |
selectSubscribedAssets | |
); | |
constructor(private store: Store<EntityState<PriceState>>) {} | |
public createPriceSubscription(assetId: string) { | |
this.addInitialPrice(assetId); | |
this.createSubscription(assetId); | |
} | |
public getPriceForAsset(assetId: string): Observable<string> { | |
return this.store.select(selectPriceForAsset(assetId)); | |
} | |
private addInitialPrice(assetId: string) { | |
this.store.dispatch(addPrice({ payload: { [assetId]: '' } })); | |
} | |
private createSubscription(assetId: string) { | |
this.store.dispatch(createPriceSubscription({ payload: assetId })); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment