zoukankan      html  css  js  c++  java
  • 使用redux代码文件的组织方式

    从架构触发,开始一个新应用的时候,代码文件的组织方式一定要考虑好

    如果之前使用过mvc的框架那么对按角色组织方式一定不陌生

    角色组织方式

    reducer/
        todoReducer.js
        filterReducer.js
    actions/
        todoActions.js
        filterActions.js
    components/
        todoList.js
        todoItem.js
        filter.js
    containers/
        todoListContainer.js
        todoItemContainer.js
        filterContainer.js

    这样组织管理redux,虽然看起来不错,但是非常不利于应用的扩展,因为如果我们想要增加新的组件,需要到好几个文件中操作

    功能组织方式

    todoList/
        action.js
        actionList.js
        index.js
        reducer.js
        view.js/
            component.js
            container.js
    filter/
        action.js
        actionTypes.js
        index.js
        reducer.js
            view/
                component.js
                container.js

    这样每一个文件都是一个功能模块,这样修改功能,只需要找对应的目录就可以,也就是做到了我们期待的模块化。

  • 相关阅读:
    AlphaToCoverage solution
    PhyreEngine3.8 MSAA resolution
    渲染错误
    tomcat
    Jupyter
    Flask
    Highcharts20151130
    CodeMirror
    响应式
    import
  • 原文地址:https://www.cnblogs.com/jinzhou/p/9296248.html
Copyright © 2011-2022 走看看