Encountering an error when trying to add effects using the 'run' method. Attempted to manually return a string, number, and other types, but nothing seems to work.
Here is the effects code snippet:
@Effect()
getRoles$: Observable<Roles[]> = this.dataPersistence.fetch(CreateActionTypes.GetRoles, {
run: (action: GetRoles) => {
return this.formService
.getRoles()
.pipe(map(roles => {
return new RolesLoaded(roles);
}));
},
onError: (action: GetRoles, error) => {
console.error(error);
return new RolesLoadError(error);
}
});
The error message received is as follows:
ERROR in apps/app/src/app/+state/create.effects.ts(32,5):
error TS2322:
Type '(action: GetRoles) => Observable' is not assignable to type '(a: GetRoles, state?: CreatePartialState) => void | Action | Observable'.
Type 'Observable' is not assignable to type 'void | Action | Observable'.