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

Place store on Ember.Route to maintain implicit record loading #7765

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ module.exports = {
WeakMap: true,
Set: true,
Promise: false,
Symbol: true,
},
env: {
browser: true,
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ jobs:
matrix:
release: [ember-release, ember-beta]
include:
- release: ember-release
continue-on-error: true
- release: ember-beta
continue-on-error: true
runs-on: ubuntu-latest
Expand Down
19 changes: 19 additions & 0 deletions packages/-ember-data/addon/setup-container.js
Original file line number Diff line number Diff line change
@@ -1,8 +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';

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

function initializeStore(application) {
// we can just use registerOptionsForType when we no longer
// support (deprecated) versions of @ember/test-helpers
Expand Down Expand Up @@ -46,6 +50,21 @@ function initializeStore(application) {
}
}

// Implicit injection was removed. This is a replacement for Ember Route implicit store for >= v4.0
Route.reopen({
get store() {
if (this[EMBER_DATA_STORE]) {
return this[EMBER_DATA_STORE];
}

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

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