Skip to content

Commit

Permalink
Place store on Ember.Route to maintain implicit record loading
Browse files Browse the repository at this point in the history
  • Loading branch information
snewcomer committed Nov 20, 2021
1 parent 0fad31d commit 3a69d25
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/-ember-data/addon/setup-container.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { getOwner } from '@ember/application';
import { deprecate } from '@ember/debug';
import Route from '@ember/routing/route';
import { DEBUG } from '@glimmer/env';

import Store from '@ember-data/store';
import { symbol } from '@ember-data/store/-private';

const EMBER_DATA_STORE = symbol('ember-data-store');

function initializeStore(application) {
// we can just use registerOptionsForType when we no longer
Expand Down Expand Up @@ -46,6 +51,22 @@ function initializeStore(application) {
}
}

// Implicit injection was removed. This is a replacement for Ember Route implicit store
// https://github.com/emberjs/rfcs/pull/774
Object.defineProperty(Route, 'store', {
get() {
if (this[EMBER_DATA_STORE]) {
return this[EMBER_DATA_STORE];
}

const store = getOwner(this).lookup('service:store');
return store;
},
set(value) {
this[EMBER_DATA_STORE] = value;
},
});

export default function setupContainer(application) {
initializeStore(application);
}

0 comments on commit 3a69d25

Please sign in to comment.