Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用 Redux 作为内核 #5

Open
jinzhubaofu opened this issue Dec 8, 2016 · 1 comment
Open

使用 Redux 作为内核 #5

jinzhubaofu opened this issue Dec 8, 2016 · 1 comment
Assignees
Milestone

Comments

@jinzhubaofu
Copy link
Owner

Redux 已然是 Flux 方案中的佼佼者,不必重复造轮子,直接使用 Redux 即可;

@jinzhubaofu jinzhubaofu self-assigned this Dec 8, 2016
@jinzhubaofu jinzhubaofu added this to the 2.0 milestone Dec 8, 2016
@jinzhubaofu
Copy link
Owner Author

jinzhubaofu commented Dec 12, 2016

breaking changes:

API 变化

  1. 移除了 connect / composeReducer / bindActions 等 API,请直接使用 redux / react-redux 提供的对应 api;

  2. ei.actions 现在是 actionCreators,包含了 init 和 replace 两个 action creator; 现在,ei 还提供了 ei.actionTypes,包含 INIT 和 REPLACE 两个常量,原有的 INIT 常量的文本值也发生了变化,添加了前缀变为 ei/INIT;而 REPLACE 的文本值为 ei/REPLACE

    示例:

    ei.actionTypes = {INIT: 'ei/INIT', REPLACE: 'ei/REPLACE'};
    ei.actions = {init: () => {}, replace: {}};

    REPLACEreplace 是用于 page.setState() 的内部实现,不建议直接使用;

  3. middlewares 现在的 api 为 page => store => next => action => {};

    即接受 page 实例,返回一个标准的 redux middleware;

    代码示例:

    module.exports = function (page) {
    
      return store => next => action => {
    
        if (typeof action !== 'function') {
            let {event, type} = action;
            page.emit(event || type, action);
        }
    
        return next(action);
    
      };
    
    };

构建相关变化

构建工具

edp 切换到 gulpwebpack

产物

现在不再分别针对 node 和 front end 提供两份不同的代码,只提供一份 umd 格式的合并压缩版本代码;具体的:

  1. 移除了原有的 front end 代码 dist 目录;
  2. 原有的 node 发布代码现在使用 umd,存放在 lib/ei.js,作为主入口

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant