Skip to content

Instantly share code, notes, and snippets.

serhii_ter SerhiiBilyk

Block or report user

Report or block SerhiiBilyk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View reducer.ts
import { ActionPayload, AllActionsPayload, Constants, IActionMap } from './actionFactory';
type ReducerCase<P> = (state: IStore, payload: P) => IStore;
type IReducer = { [P in keyof Record<Constants, ReducerCase<AllActionsPayload>>]: ReducerCase<IActionMap[P]> };
export const reducer: IReducer = {
ACTION_NAMESPACE: (state, payload) => {
const { id, mode } = payload;
return state
View actions.ts
import { Constants as _, createAction } from './actionFactory';
export const initialAction = createAction<_.ACTION_NAMESPACE>(_.ACTION_NAMESPACE);
@SerhiiBilyk
SerhiiBilyk / actionFactory.ts
Last active Jun 13, 2019
TS Redux action factory
View actionFactory.ts
import { Action } from 'redux';
export enum Constants {
ACTION_NAMESPACE = 'ACTION_NAMESPACE',
}
export type ActionPayload<T, P> = Action<T> & { payload: P };
interface IPayload{
id: string;
You can’t perform that action at this time.