Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Offline actions and Redux Toolkit 'createAction' #490

Open
barryf001 opened this issue Feb 7, 2022 · 0 comments
Open

Offline actions and Redux Toolkit 'createAction' #490

barryf001 opened this issue Feb 7, 2022 · 0 comments

Comments

@barryf001
Copy link

barryf001 commented Feb 7, 2022

Hi,

I have another Redux-Toolkit integration question.

Is it possible to install an action creator (createAction) as a callback fruntion for 'commit' and 'rollback' variables when initiating offline request?

For example:

//standard action-creator
const doSomethingOnCommit= ( payload, meta) => ({
   type: "doSomethingOnCommit"
   payload,
   meta
} )

//using redux-tookit action creator helper
const doSomethingOnRollback= createAction('doSomethingOnRollback', (payload, meta) => ({
   payload,
   meta
} )

store.dispatch({
    type: "doSomethingOffline"
    payload: {},
    meta: {
      offline: {
          effect...
     },
     commit:  (payload, meta: { id: 100 }) => doSomethingOnCommit(payload, meta),
     rollback: (payload, meta: { id: 100 }) => doSomethingOnRollback(payload, meta),
   }
})

Any response appreciated - cheers!

@barryf001 barryf001 changed the title Offline effects and Redux Toolkit 'createAction' Offline actions and Redux Toolkit 'createAction' Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant