I'm using third party library which give promises, but i need to wrap it to Observable in ngrx effect. The idea is to dispatch new action when app is initialized successfully. But i need to dispatch the data when the promise is resolved.
classOne.promise().then(result =>
nested.OnemorePromise(result).then(result2 =>
//(result2) dispatch new action here (result2)
)
);
I created something like this:
@Effect()
initializeValue$: Observable<Action> = this.actions$.pipe(
ofAction(AppInitializeAction),
map(action => {
classOne.promise().then(result =>
nested.OnemorePromise(result).then(result2 =>
this.store.dispatch(new Action(result2))
// ideally just - return new Action(result2)
)
);
})
upd:
@Effect()
initializeValue$: Observable<Action> = this.actions$.pipe(
ofAction(AppInitializeAction),
map(action => {
return from(classOne.promise()).map(result => {
console.log(result)
})
})
);
map is not a function.
from(classOne.promise()).pipe(map(result
– Julius