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

Async and dispatch clarification #17

Closed
magneticflux- opened this issue Mar 5, 2019 · 4 comments
Closed

Async and dispatch clarification #17

magneticflux- opened this issue Mar 5, 2019 · 4 comments
Labels
question Further information is requested

Comments

@magneticflux-
Copy link

I don't fully understand how to implement asynchronous actions or dispatch more actions from a handler. Could you clarify this in document?

@the-dr-lazy
Copy link
Owner

Hi, I think you are questioning about usage of deox with thunk. Am I right?

@magneticflux-
Copy link
Author

Yes, or with another similar middleware such as redux-promise. How do they interact with the handler-list-creator function?

@the-dr-lazy
Copy link
Owner

the-dr-lazy commented Mar 8, 2019

Middlewares in redux don't change the anatomy and functionality of reducers. Action handlers are fundamental reducer portions. So there should not be any direct interaction of the middlewares with action handlers.
A basic example of deox with redux-thunk can be like below:

const increment = createAction('INCREMENT')

const incrementAsync = () => dispatch =>
  setTimeout(() => dispatch(increment()), 500)

const root = createReducer(0, handleAction => [
  handleAction(increment, state => state + 1)
])

store.dispatch(incrementAsync())

@the-dr-lazy the-dr-lazy added the question Further information is requested label Mar 8, 2019
@the-dr-lazy
Copy link
Owner

the-dr-lazy commented Mar 10, 2019

I will close the issue but feel free to re-open it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants