mirror of
https://github.com/fergalmoran/Readarr.git
synced 2026-01-15 13:16:13 +00:00
Ability to cancel an import lookup/search at any point. Ability to move artist path from Artist Edit or bulk move from Mass Editor. Trigger manual import for Artist path from Artist Detail page. Pulled from Sonarr
28 lines
582 B
JavaScript
28 lines
582 B
JavaScript
const thunks = {};
|
|
|
|
function identity(payload) {
|
|
return payload;
|
|
}
|
|
|
|
export function createThunk(type, identityFunction = identity) {
|
|
return function(payload = {}) {
|
|
return function(dispatch, getState) {
|
|
const thunk = thunks[type];
|
|
|
|
if (thunk) {
|
|
return thunk(getState, identityFunction(payload), dispatch);
|
|
}
|
|
|
|
throw Error(`Thunk handler has not been registered for ${type}`);
|
|
};
|
|
};
|
|
}
|
|
|
|
export function handleThunks(handlers) {
|
|
const types = Object.keys(handlers);
|
|
|
|
types.forEach((type) => {
|
|
thunks[type] = handlers[type];
|
|
});
|
|
}
|