Open dimitropoulos opened 4 years ago
I am looking at using redux-beacon to integrate analytics from the point of my redux store. To do this I need to add meta to some actions. So I basically have typical createAction that looks like this, let's say:
redux-beacon
meta
createAction
export const setExpertModeAction = createAction('config/SET_EXPERT_MODE')<boolean>();
I'm using this with createReducer like
createReducer
export const configReducer = createReducer(initialState) .handleAction(setExpertModeAction, (state, action) => ({ ...state, expertMode: action.payload });
And in my code I just have
dispatch(setExpertModeAction(true))
My problem is I want to, at the level of the creation of the action, create meta for the analytics.
I was able to mock this out as follows:
export interface ActionMetaType { analytics?: { eventName: string; otherEventAttr?: number; }; } export const setExpertModeAction = <T extends boolean>(payload: T) => ( createAction('config/SET_EXPERT_MODE')<T, ActionMetaType>()( payload, { analytics: { eventName: payload ? 'enabled expert mode' : 'disabled expert mode', }, }, ) );
That way, when I dispatch the action it doesn't need the meta to be there, just like before. My issue is, though, that when I run this I get:
Error: Argument 1 is invalid, it should be an action-creator instance from "typesafe-actions" or action type of type: string | symbol
Any suggestions?
I am looking at using
redux-beacon
to integrate analytics from the point of my redux store. To do this I need to addmeta
to some actions. So I basically have typicalcreateAction
that looks like this, let's say:I'm using this with
createReducer
likeAnd in my code I just have
My problem is I want to, at the level of the creation of the action, create meta for the analytics.
I was able to mock this out as follows:
That way, when I dispatch the action it doesn't need the meta to be there, just like before. My issue is, though, that when I run this I get:
Any suggestions?