| I also don't like having all those constants like LOADING_PRODUCTS ... And I don't have them, instead this is how you create a type safes actions with typesafe-actions package. export const signIn = {
request: createAction("auth/signin/request")(),
success: createAction("auth/signin/success")<{ user: User }>(),
error: createAction("auth/signin/error")<Error>(),
};
getType is a function from typesafe-actions as well.Not trying to sell you on Redux, just to address your point about the constants. About having to write many Epics, well, end of the day, all the Epics have this shape. export const signInEpic = (action$: Observable<Action>) =>
action$.pipe(
filter(isActionOf(signIn.request)),
switchMap(() =>
from(signInLogic()).pipe(
map((user: User) => {
return signIn.success({ user });
}),
catchError((error) => of(signIn.error(error)))
)
)
);
isActionOf is another typesafe-actions function...I'm not claiming it's superior approach or faster, it's an approach that worked for me for medium/large apps, to collaborate with other developers. I'm pretty sure you are right about the Svelte cool things you saying I wish I had more time to look into it. |
https://redux-toolkit.js.org