Skip to content

Instantly share code, notes, and snippets.

@leondmello
Created April 6, 2018 21:28
Show Gist options
  • Save leondmello/ae0d15e2fe051d6b16d4b898cf750aa3 to your computer and use it in GitHub Desktop.
Save leondmello/ae0d15e2fe051d6b16d4b898cf750aa3 to your computer and use it in GitHub Desktop.
Memoizer app model
import DS from 'ember-data';
import ModelMixin from 'ember-data-extensions/mixins/model';
import _ from 'lodash';
const AppModel = DS.Model.extend(ModelMixin);
const modelViewName = _.memoize(function () {
<some code>
}, function () {
return this.modelName;
});
const attributeLabels = _.memoize(function (store) {
<some code>
}, function () {
return this.modelName;
});
export default AppModel.extend({
}).reopenClass({
overriddenModelViewName: () => {},
overriddenAttributeLabels: () => {},
modelViewName: modelViewName,
attributeLabels: attributeLabels
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment