How to use dva-core - 10 common examples

To help you get started, we’ve selected a few dva-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github w771854332 / rn-twitter / src / utils / dva.tsx View on Github external
export default function(options: DvaOption & {
  models: Model[],
}) {
  const { models, ...restOpts } = options;
  const app = create(restOpts);
  // HMR workaround
  if (!global.registered) {
    models.forEach(model => app.model(model));
  }
  global.registered = true;

  app.start();
  // eslint-disable-next-line no-underscore-dangle
  const store = app._store;

  app.start = container => () => {container};
  app.getStore = () => store;

  return app;
}
github hugetiny / quit-smoking / src / utils / dva.js View on Github external
function createApp (opt) {
  // redux日志
  // opt.onAction = [createLogger()];
  app = create(opt)
  app.use(createLoading({}))

  // 适配支付宝小程序
  if (Taro.getEnv() === Taro.ENV_TYPE.ALIPAY) {
    global = {}
  }

  if (!global.registered) opt.models.forEach(model => app.model(model))
  global.registered = true
  app.start()

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

  dispatch = store.dispatch
github EasyTuan / taro-msparis / src / utils / dva.js View on Github external
function createApp(opt) {
  // redux日志
  // opt.onAction = [createLogger()];
  app = create(opt);
  app.use(createLoading({}));

  // 适配支付宝小程序
  if (Taro.getEnv() === Taro.ENV_TYPE.ALIPAY) {
    global = {};
  }

  if (!global.registered) opt.models.forEach(model => app.model(model));
  global.registered = true;
  app.start();

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

  dispatch = store.dispatch;
github dvajs / dva / packages / dva / src / index.js View on Github external
export default function(opts = {}) {
  const history = opts.history || createHashHistory();
  const createOpts = {
    initialReducer: {
      router: connectRouter(history),
    },
    setupMiddlewares(middlewares) {
      return [routerMiddleware(history), ...middlewares];
    },
    setupApp(app) {
      app._history = patchHistory(history);
    },
  };

  const app = create(opts, createOpts);
  const oldAppStart = app.start;
  app.router = router;
  app.start = start;
  return app;

  function router(router) {
    invariant(
      isFunction(router),
      `[app.router] router should be function, but got ${typeof router}`,
    );
    app._router = router;
  }

  function start(container) {
    // 允许 container 是字符串,然后用 querySelector 找元素
    if (isString(container)) {
github dvajs / dva / packages / dva-react-router-3 / src / index.js View on Github external
const createOpts = {
    initialReducer: {
      routing,
    },
    setupMiddlewares(middlewares) {
      return [
        routerMiddleware(history),
        ...middlewares,
      ];
    },
    setupApp(app) {
      app._history = patchHistory(syncHistoryWithStore(history, app._store));
    },
  };

  const app = core.create(opts, createOpts);
  const oldAppStart = app.start;
  app.router = router;
  app.start = start;
  return app;

  function router(router) {
    invariant(
      isFunction(router),
      `[app.router] router should be function, but got ${typeof router}`,
    );
    app._router = router;
  }

  function start(container) {
    // 允许 container 是字符串,然后用 querySelector 找元素
    if (isString(container)) {
github dvajs / dva / packages / dva-no-router / src / index.js View on Github external
export default function (opts = {}) {
  const app = core.create(opts);
  const oldAppStart = app.start;
  app.router = router;
  app.start = start;
  return app;

  function router(router) {
    invariant(
      isFunction(router),
      `[app.router] router should be function, but got ${typeof router}`,
    );
    app._router = router;
  }

  function start(container) {
    // 允许 container 是字符串,然后用 querySelector 找元素
    if (isString(container)) {
github Martian-in-Earth / dva-vue / packages / dva-vue / es / index.js View on Github external
};
  var start = function start(container) {
    // 允许 container 是字符串,然后用 querySelector 找元素
    if (isString(container)) {
      container = document.querySelector(container);
      invariant(container, '[app.start] container ' + container + ' not found');
    }
    // 并且是 HTMLElement
    invariant(!container || isHTMLElement(container), '[app.start] container should be HTMLElement');
    // 路由必须提前注册
    invariant(app._router, '[app.start] router must be registered before app.start()');
    oldAppStart.call(app);
    var store = app._store;
    render(container, store, app, app._router);
  };
  var app = core.create(opts, createOpts);
  var oldAppStart = app.start;
  app.router = router;
  app.start = start;
  app.plugin = Vue.use;
  return app;
}
github zuoge85 / taro-dva / src / dva.js View on Github external
function createApp(opt) {
  opt.onAction = [createLogger()];
  app = create(opt);
  app.use(createLoading({}));

  if (!global.registered) opt.models.forEach(model => app.model(model));
  global.registered = true;
  app.start();

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

  dispatch = store.dispatch;

  app.dispatch = dispatch;
  return app;
}
github huangzhuangjia / taro-music / src / dva.ts View on Github external
function createApp(options?: any) {
  const { models } = options
  if (process.env.NODE_ENV === 'development') {
    options.onAction = [createLogger()]
  }
  app = create({
    ...options
  })
  app.use(createLoading({}))

  if (!global.registered) models.forEach((model) => app.model(model))
  global.registered = true
  app.start()

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

  dispatch = store.dispatch

  app.dispatch = dispatch
  return app
}
github apersonw / taro-mall / client / src / utils / dva.js View on Github external
function createApp(opt) {
  app = create(opt);
  app.use(createLoading({}));

  if (!global.registered) {
    opt.models.forEach(model => app.model(model));
    global.registered = true;
  }
  app.start();
  store = app._store;
  app.getStore = () => store;

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

dva-core

The core lightweight library for dva, based on redux and redux-saga.

MIT
Latest version published 4 years ago

Package Health Score

58 / 100
Full package analysis