Releases: piotrwitek/typesafe-actions
Releases · piotrwitek/typesafe-actions
v5.1.0
Breaking changes
- In
v5
all the deprecatedv4
creator functions are available underdeprecated
named import to help with incremental migration.
// before
import { createAction, createStandardAction, createCustomAction } from "typesafe-actions"
// after
import { deprecated } from "typesafe-actions"
const { createAction, createStandardAction, createCustomAction } = deprecated;
createStandardAction
was renamed tocreateAction
and.map
method was removed in favor of simplerredux-actions
style API.
// before
const withMappedPayloadAndMeta = createStandardAction(
'CREATE_STANDARD_ACTION'
).map(({ username, message }: Notification) => ({
payload: `${username}: ${message}`,
meta: { username, message },
}));
// after
const withMappedPayloadAndMeta = createAction(
'CREATE_STANDARD_ACTION',
({ username, message }: Notification) => `${username}: ${message}`, // payload creator
({ username, message }: Notification) => ({ username, message }) // meta creator
)();
v4
version ofcreateAction
was removed. I suggest to refactor to use a newcreateAction
as in point2
, which was simplified and extended to supportredux-actions
style API.
// before
const withPayloadAndMeta = createAction('CREATE_ACTION', resolve => {
return (id: number, token: string) => resolve(id, token);
});
// after
const withPayloadAndMeta = createAction(
'CREATE_ACTION',
(id: number, token: string) => id, // payload creator
(id: number, token: string) => token // meta creator
})();
createCustomAction
- API was greatly simplified, now it's used like this:
// before
const add = createCustomAction('CUSTOM', type => {
return (first: number, second: number) => ({ type, customProp1: first, customProp2: second });
});
// after
const add = createCustomAction(
'CUSTOM',
(first: number, second: number) => ({ customProp1: first, customProp2: second })
);
AsyncActionCreator
should be just renamed toAsyncActionCreatorBuilder
.
// before
import { AsyncActionCreator } from "typesafe-actions"
//after
import { AsyncActionCreatorBuilder } from "typesafe-actions"
New
- Rewrite and simplify
createAction
&createAsyncAction
API (#192)
Improvements
v4.4.2
v4.4.1
v4.4.0
v4.3.0
v4.2.1
v4.2.0
v4.1.4
Improvements
- Updated createReducer
handlers
property type to show the correct type of only already added handlers