1

我有兴趣了解更多关于 redux-saga 的信息,我很好奇它是否可以帮助解决我想解决的问题。通常,对于异步 API 调用,围绕正在运行的任务的状态有各种常见模式,例如它是否失败是否仍在运行是否成功完成。. 我一直在将这些作为分派的单独操作实现,但对于每个 API 调用,我发现我至少有 3 个相应的操作,我必须分别命名、管理和分派。为了缓解这种情况,我希望实现自己的抽象,但首先想验证 redux-saga 是否包含一些标准方法来跟踪 API 调用中的这些状态值,我可以使用这些方法而不是重新发明轮子。

也许还有其他库可能会有所帮助,但因为我对 redux-saga 感兴趣的其他原因,我主要想知道它是否提供了我所追求的东西。

4

1 回答 1

2

redux-saga's main purpose is to handle complex async operations that span across multiple actions (like login, then call authorization api, then refresh authorization each x seconds until user logout).

redux-saga allows you to modify the state by dispatching actions to the store but it doesn't automatically update some status on some request. You'll have to tell it when and where to store the status. So maybe it's not directly useful for your case.

于 2016-02-05T00:13:04.787 回答