Looking for some insights on this issue
Currently working with ngrx and attempting to utilize multiple switchMaps to call various action classes.
Defined Actions:
export class BlogAddedAction implements Action {
readonly type = BLOG_ADDED_ACTION;
constructor(public payload:any) {
}
}
export class CrudSucessAction implements Action {
readonly type = CRUD_SUCCESS_ACTION;
constructor(public payload:any) {
}
}
export class BlogAddedToDBAction implements Action {
readonly type = BLOG_ADDED_TO_DB_ACTION;
constructor(public payload:any) {
}
}
effects.ts:
@Effect() addBlog$: Observable<any> = this.actions$
.ofType<BlogAddedAction>(BLOG_ADDED_ACTION)
.switchMap(action => {
console.log(action)
return this.blogService.addBlog(action.payload.blog)
})
.switchMap((action)=>new BlogAddedToDBAction(action))
.map((action)=>new CrudSucessAction(action))
}
Encountering a TypeScript error:
[ts]
Argument of type '(action: Blog) => BlogAddedToDBAction' is not
assignable to parameter of type '(value: Blog, index: number) => ObservableInput<{}>'.Type 'BlogAddedToDBAction' is not assignable to type 'ObservableInput<{}>'.
Type 'BlogAddedToDBAction' is not assignable to type 'ArrayLike<{}>'.Property 'length' is missing in type 'BlogAddedToDBAction'.
Attempted using map instead of a second switchMap but BlogAddedToDBAction
is not being executed.