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

[CHORE] inject the Model specific _modelForMixin implementation into the store from the Model package #6800

Closed
wants to merge 5 commits into from

Conversation

Gaurav0
Copy link
Contributor

@Gaurav0 Gaurav0 commented Nov 25, 2019

For #6166

}
return _Model;
}
import { RecordInstance } from '../ts-interfaces/record-instance';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RecordInstance is for the instantiated record instances, I believe based on usage below you are in need of ModelSchema or DSModelSchema

let factory = cache[normalizedModelName];

if (!factory) {
factory = _lookupModelFactory(store, normalizedModelName);

if (!factory) {
//Support looking up mixins as base types for polymorphic relationships
factory = _modelForMixin(store, normalizedModelName);
factory = store._modelForMixin(normalizedModelName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of adding a private method to store and injecting it from the model package, we should use the HAS_MODEL_PACKAGE build flag to conditionally import a private function from that package.

let _modelForMixin;
if (HAS_MODEL_PACKAGE) {
 _modelForMixin = require('@ember-data/model/-private')._modelForMixin;
}

// ....

if (HAS_MODEL_PACKAGE) {
  factory = _modelForMixin(store, normalizedModelName);
}

possibly with a module scope cache for the method to avoid looking it up each time.

@runspired
Copy link
Contributor

Closing in favor of #6802

@runspired runspired closed this Nov 26, 2019
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

Successfully merging this pull request may close these issues.

2 participants