Git Product home page Git Product logo

dva-app's Introduction

1.背景

目前工程统一采用React + redux + saga,redux + redux-sage 层,由于直接使用写法非常繁琐,所以有了rematch、dva等,可以大大简化使用流程,提高开发效率。由于dva做的比较重,打算只是用dva-core,dva中的核心功能。

2.dva-core 写法(适用 TS)

  • 可以先了解 dva 的用法,文档:dva 官方文档

  • 或者手动操作,具体使用如下步骤:

    • 安装 dva:npm install dva-core
    • 项目 ./src 中新建 dva.ts
    import { create } from 'dva-core';

    let app;
    function createApp(opt) {
        app = create(opt);
        if (!global.registered) {
            opt.models.forEach(model => app.model(model));
        }
        global.registered = true;
        app.start();

        const store = app._store;
        app.getStore = () => store;

        const { dispatch } = store;
        app.dispatch = dispatch;
        return app;
    }

    export default {
        createApp,
        getDispatch() {
            return app.dispatch;
        },
    };

dva-app's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.