Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

110
Views
Handle complex async actions in Redux, and state discrepency

Let's say I have a state that looks like this:

enum PlayState {
    Playing,
    Paused,
    Error
}

const initialState = {
    playState:  PlayState.Playing,
};

This holds the state of the currently selected audio player. Using a control panel, user can change the state of the player from playing to paused and vice versa. Audio player react component listens to state changes and calls the audio player SDK (which can take a few seconds, and can error out potentially).

Since this is like an async procedure, can somehow async thunk be applied in this case, or the request, success, failure pattern? How to correctly handle discrepency between the TRUE state of the audio player, and the intended (requested) state?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Yes, it can be done using thunk, also using redux-observable, saga, suspense, hooks, and other approaches.

Here is a nice article showing examples with thunk, saga, suspense, and hooks: https://www.freecodecamp.org/news/loading-data-in-react-redux-thunk-redux-saga-suspense-hooks-666b21da1569

I think once you get familiar with even one of the above your problem will be a breeze to solve. :)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!