My compomnet.tx file had some store subscribing method like below.
readonly selectedId$: Observable<string | null> = this.store.select(selectedId)
.pipe(shareReplayUntil(this.destroySub));
They are normally declared as variables. But I need to take this current value from them and pass it to another method in the same .ts file.
onScanId() {
// here I need to take subscribe id
this.store.dispatch(scanId({ Id: "1" }));
}
I need some expert help to resolve this. I prefer I can remove this read-only thing and assign it to directly variable, and use it in Html, the file also.
Currently, I take value using an async pipe, { selectedId$ | async }
What is preventing you from just doing
you subscribe yo your observable using
take(1)
to get a single value and forget about it. then just subscribe to it, get the id and dispatch