Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

117
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda