alibaba / fish-redux

An assembled flutter application framework.
https://github.com/alibaba/fish-redux
Apache License 2.0
7.33k stars 843 forks source link

effectMiddleware的AbstractLogic<dynamic> logic含义 #566

Closed jefferybai closed 4 years ago

jefferybai commented 4 years ago
/// 简单的 Effect AOP
/// 只针对页面的生命周期进行打印
EffectMiddleware<T> _pageAnalyticsMiddleware<T>({String tag = 'redux'}) {
  return (AbstractLogic<dynamic> logic, Store<T> store) {
    return (Effect<dynamic> effect) {
      return (Action action, Context<dynamic> ctx) {
        if (logic is Page<dynamic, dynamic> && action.type is Lifecycle) {
          print('${logic.runtimeType} ${action.type.toString()} ');
        }
        return effect?.call(action, ctx);
      };
    };
  };
}

请问effectMiddleware第一个函数的形参AbstractLogic logic,代表什么?

doubleSkinMilk commented 4 years ago

今天刚好看到这,在redux_component->enhancer.dart文件中; Effect<K> effectEnhance<K>( Effect<K> effect, AbstractLogic<K> logic, Store<T> store, ) => _effectEnhancer?.call(logic, store)?.call(_inverterEffect<K>(effect)) ?? effect; pageAnalyticsMiddleware在这里被调用的; logic可以理解成发起此次effect的持有者,可能是page,可能是component