redux-toolkit
redux-toolkit copied to clipboard
Is it safe to use action.meta.arg.originalArgs for passing custom options to a rejected action listener?
I'm working on a listener that handles rejected actions, specifically focusing on conditionally logging 412 errors based on certain conditions. Here's a simplified version of my listener:
// Pseudo listener
export const create412ErrorListener = () => ({
predicate: (action: PayloadAction) => isRejected(action) && is412Error(action),
effect: (action: PayloadAction) => {
if (action?.meta?.arg?.originalArgs?.opts?.log412) {
Logger.warn(action.payload)
}
},
});
In this case, I'm checking action.meta.arg.originalArgs.opts.log412 to decide whether to log 412 errors.
Additionally, in one of my components, I pass this option like so:
// Some component
const { data } = useQuery({
criteria,
opts: { log412: true },
});
My Question:
Is it safe to rely on action.meta.arg.originalArgs for passing custom options like this?
Specifically, is originalArgs meant for public use, or is it primarily intended for internal purposes?
I would consider it an implementation detail, but I think the chances of us changing it in practice are low.