In a straightforward scenario, I have an upload action on the page that looks like this:
onUpload$: Subject<SomeUpload> = new Subject<SomeUpload>();
uploadAction$: Observable<Action> = this.onUpload$.map(entity => this.someActionService.upload(entity));
This uploadAction$ is subscribed to in an Angular2 component based on state.
this.subscription = Observable.merge(
this.uploadAction$
).subscribe(this.store);
The action sends a base64 image to the server and receives a URL in response. This URL can be obtained like this:
someResponseUrl$: Observable<String> = this.store.let(getSomeUrlFromState());
I need to create a callback functionality as the URL is not used in templates, but rather for manipulating data in the code. Can someone provide guidance on how to create an action from this observable string to retrieve data and make a callback with it? Thank you in advance!
P.S. I've attempted something like this:
uploadAction$: Observable<Action> = this.onUpload$.map(entity =>
this.someActionService.upload(entity))
.do(() => {
const subscription =
this.store.let(getSomeUrlFromState()).subscribe(url => {
console.log(url)
});
});
It works, but I feel there might be a better solution...