open-vault/ui/app/mixins/unload-model-route.js
Matthew Irish d509588cd2
Ember update (#5386)
Ember update - update ember-cli, ember-data, and ember to 3.4 series
2018-09-25 11:28:26 -05:00

23 lines
506 B
JavaScript

import Mixin from '@ember/object/mixin';
// removes Ember Data records from the cache when the model
// changes or you move away from the current route
export default Mixin.create({
modelPath: 'model',
unloadModel() {
const model = this.controller.get(this.get('modelPath'));
if (!model || !model.unloadRecord) {
return;
}
this.store.unloadRecord(model);
model.destroy();
},
actions: {
willTransition() {
this.unloadModel();
return true;
},
},
});