You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why createAction(string, fn) has first parameter pressent? Because i dont see difference between these two:
typeTYPE=(param: any)=>{type: "AAA",payload: {param: any}};// yoursconstaction: TYPE=createAction("AAA",(param: any)=>({payload: { param },type: "AAA",}));// mine defined bellowconstaction: TYPE=createAction2((param: any)=>({payload: { param },type: "AAA",}));exportfunctioncreateAction2<Textendsstring,ACextends(...args: any[])=>FluxStandardAction<T>>(creator: T|AC,): AC&TypeGetter<T>{lettype: T;letactionCreator: AC&TypeGetter<T>;if(typeofcreator==='string'){actionCreator=(()=>({ type }))asAC&TypeGetter<T>;type=creator;}elseif(typeofcreator==='function'){actionCreator=creatorasAC&TypeGetter<T>;type=actionCreator().type;}else{thrownewError('argument must be of type string or function');}(actionCreatorasTypeGetter<T>).getType=()=>type;returnactionCreator;}
only thing, that is funky is calling creatorFunction to determine action type ...
Why? Lazynest :) - currenly i need to write action type twice ....
PS: Tryied to create PR, but same code fails to compile in fork project (compiles in my test project)
The text was updated successfully, but these errors were encountered:
// yours really is these two togethertypeTYPE=(param: any)=>{type: "AAA",payload: {param: any}};// +constaction: TYPE=createAction2((param: any)=>({payload: { param },type: "AAA",}));// mine is really only a decorator - I do not need the extra TYPE declaration which is twice more boilerplate// moreover I will get rid of first param in TS 2.8 :) double winconstaction=createAction("AAA",(param: any)=>({payload: { param },type: "AAA",}));
Why createAction(string, fn) has first parameter pressent? Because i dont see difference between these two:
only thing, that is funky is calling creatorFunction to determine action type ...
Why? Lazynest :) - currenly i need to write action type twice ....
PS: Tryied to create PR, but same code fails to compile in fork project (compiles in my test project)
The text was updated successfully, but these errors were encountered: