Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Is it safe to use action.meta.arg.originalArgs for passing custom options to a rejected action listener? #4659

Open
AndreasNH opened this issue Oct 10, 2024 · 1 comment

Comments

@AndreasNH
Copy link

AndreasNH commented Oct 10, 2024

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?

@EskiMojo14
Copy link
Collaborator

I would consider it an implementation detail, but I think the chances of us changing it in practice are low.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants