Open JonnyBGod opened 7 years ago
Major refactor though, will have to do it next week.
@JonnyBGod - if you can provide more details, i'll be happy to add this. i don't have much experience with ngrx though, so i may need some guidance.
I will try to update the ngrx implementation next week.
Did a few changes since this first version.
but for reference related to this issue it should be changed to something like this:
actions:
actions.create = class implements Action {
public readonly type = actionTypes['CREATE'];
constructor(public payload: any, **public meta?: any**) { }
};
effects:
protected create: Observable<LoopbackAction> = this.actions$
.ofType(this.actionTypes.CREATE)
.mergeMap((action: LoopbackAction) =>
this.apiService.create(action.payload)
.map((response) => new this.actions.createSuccess(response, **action.meta**))
.catch((error) => concat(
of(new this.actions.createFail(error, **action.meta**)),
of(new LoopbackErrorActions.error(error, **action.meta**))
))
);
without the ** of course.
Another refactor should be the reducers helper methods.
should change to
export const getLoopbackAuthState = (state: any) => state.loopbackAuth;
export const getLoopbackAuthToken = (state: any) => state.loopbackAuth;
export const getLoopbackAuthUser = (state: any) => state.loopbackAuth.user;
export const getLoopbackAuthUserId = (state: any) => state.loopbackAuth.userId;
and similar with other reducers.
@JonnyBGod good to hear you can spend some time on this soon. I hope to get this puppy out asap.
Let's hop on a call when you have time so we can iron out the things and talk through the steps we need to take to finalize.
also still related to this issue, for the meta parameter to validate with TS we have to add the following to BaseModels.ts
export interface LoopbackAction extends Action {
meta?: any;
}
@beeman Yes, sure will get back to you for the call hopefully mid next week.
Sorry for almost two months of absence here but been busy. But I see you got a few extra hand on it 👍
Yeah the starter is doing great with help from @brannon-darby and @kattsushi. We aim to release a beta version once the ngrx stuff lands in the sdk-builder alpha/beta
This would provide an easy way to pass extra data for action extensibility.
Good example would be for an Alert reducer, enabling us to pass "success/fail" messages to be consumed by Alert Effects/Reducers.
This would work for other use cases if we keep optional param as open as possible.