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

修复model卸载后无法重新挂载bug(dynamic) #2075

Closed
wants to merge 1 commit into from

Conversation

lf7817
Copy link

@lf7817 lf7817 commented Apr 19, 2019

Checklist
  • npm test passes
  • tests are included
  • documentation is changed or added
  • commit message follows commit guidelines
Description of change
  • 修改注册model条件
    dynamic.js
var cached = {};

function registerModel(app, model) {
  model = model.default || model;

  if (!cached[model.namespace]) {
    app.model(model);
    cached[model.namespace] = 1;
  }
}

当执行app.unmodel卸载model时,并没有修改cached缓存,所以重复挂在model时,永远不会执行app.model, 应该从app._models中判断

function registerModel(app, model) {
  model = model.default || model;
  if (
    !app._models.some(item => {
      return item.namespace === model.namespace;
    })
  ) {
    app.model(model);
  }
}

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.03%) to 87.25% when pulling 9659378 on lf7817:master into 99ec56c on dvajs:master.

@sorrycc
Copy link
Member

sorrycc commented Apr 20, 2019

补个用例吧。

@stale
Copy link

stale bot commented Jun 19, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jun 19, 2019
@stale stale bot closed this Jun 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

app.unmodel 之后, dynamic 不会重复注册model
3 participants