redux 中间件和 redux-observable 史诗有什么区别?
What is the difference between a redux middleware and a redux-observable epic?
我想了解什么时候适合使用 redux middleware over a redux-observable epic(反之亦然)。
来自redux中间件documentation
It provides a third-party extension point between dispatching an action, and the moment it reaches the reducer. People use Redux middleware for logging, crash reporting, talking to an asynchronous API, routing, and more.
来自redux-observabledocumentation
While you'll most commonly produce actions out in response to some action you received in, that's not actually a requirement! Once you're inside your Epic, use any Observable patterns you desire as long as anything output from the final, returned stream, is an action.
我的理解是,redux 中间件中的操作可能会或可能不会命中 reducer,如果命中,它可能会或可能不会导致状态更改。在史诗中,你可以产生一个新的动作,它可能会或可能不会命中减速器或导致状态改变。
看起来两者都可以用来启用副作用,所以两者之间的区别对我来说变得有点模糊。
问题: FRP 基础是唯一让它们与众不同的东西,还是在应用程序的生命周期中有特定事件可以更好地处理经典中间件或史诗?
"Middleware" 是可用于自定义 Redux 存储的通用类型。 redux-observable
是一个特定的 Redux 中间件,它允许您使用 RxJS 逻辑与调度的操作进行交互。
我想了解什么时候适合使用 redux middleware over a redux-observable epic(反之亦然)。
来自redux中间件documentation
It provides a third-party extension point between dispatching an action, and the moment it reaches the reducer. People use Redux middleware for logging, crash reporting, talking to an asynchronous API, routing, and more.
来自redux-observabledocumentation
While you'll most commonly produce actions out in response to some action you received in, that's not actually a requirement! Once you're inside your Epic, use any Observable patterns you desire as long as anything output from the final, returned stream, is an action.
我的理解是,redux 中间件中的操作可能会或可能不会命中 reducer,如果命中,它可能会或可能不会导致状态更改。在史诗中,你可以产生一个新的动作,它可能会或可能不会命中减速器或导致状态改变。
看起来两者都可以用来启用副作用,所以两者之间的区别对我来说变得有点模糊。
问题: FRP 基础是唯一让它们与众不同的东西,还是在应用程序的生命周期中有特定事件可以更好地处理经典中间件或史诗?
"Middleware" 是可用于自定义 Redux 存储的通用类型。 redux-observable
是一个特定的 Redux 中间件,它允许您使用 RxJS 逻辑与调度的操作进行交互。