VP
Size: a a a
VP
NS
VP
type
у action.const isAction = (thing: any): thing is Action<any> =>
thing && 'getType' in thing && /^action/.exec(thing.getType()) !== null;
NS
type
у action.const isAction = (thing: any): thing is Action<any> =>
thing && 'getType' in thing && /^action/.exec(thing.getType()) !== null;
VP
VP
x is ReturnType<typeof declareAction>
NS
VP
NS
VP
VP
NS
VP
g
export const startСookingAction = declareAction();
export const startСookingTimeOutAction = declareAction();
export const sidebarAtom = declareAtom<SnackBarItem[]>([], (on) => [
on(startСookingAction, () => {
const item: SnackBarItem = {
key: "item",
message: "Начали готовить ваш заказ",
status: "success",
autoClose: true,
onClose: startСookingTimeOutAction, <--- Тут экшен который хотелось бы чтоб вызвался в компоненте
};
return [item];
}),
on(startСookingTimeOutAction, () => []),
]);
a
export const startСookingAction = declareAction();
export const startСookingTimeOutAction = declareAction();
export const sidebarAtom = declareAtom<SnackBarItem[]>([], (on) => [
on(startСookingAction, () => {
const item: SnackBarItem = {
key: "item",
message: "Начали готовить ваш заказ",
status: "success",
autoClose: true,
onClose: startСookingTimeOutAction, <--- Тут экшен который хотелось бы чтоб вызвался в компоненте
};
return [item];
}),
on(startСookingTimeOutAction, () => []),
]);
onClose: () => startСookingTimeOutAction(key)
и в хендлере атома на startСookingTimeOutAction соотносить key из пайлоада с соответствующим элементомg
onClose: () => startСookingTimeOutAction(key)
и в хендлере атома на startСookingTimeOutAction соотносить key из пайлоада с соответствующим элементомexport const startСookingAction = declareAction();
export const startСookingTimeOutAction = declareAction<string>();
export const sidebarAtom = declareAtom<SnackBarItem[]>([], (on) => [
on(startСookingAction, () => {
const item: SnackBarItem = {
key: "item",
message: "Начали готовить ваш заказ",
status: "success",
// autoClose: true,
onClose: () => startСookingTimeOutAction("item"),
};
return [item];
}),
on(startСookingTimeOutAction, (state, payload) => {
console.log(payload);
console.log(state);
return [];
}),
]);
a
a
onClose
объявляется в родителе, через useAction(startСookingTimeOutAction
), т.е. не является частью элемента в списке