Skip to content

Commit

Permalink
[cleanup]: Remove implicit store injection slated for Ember v4.0.0 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
snewcomer committed Sep 30, 2021
1 parent 5a49ec3 commit e973920
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 51 deletions.
7 changes: 0 additions & 7 deletions packages/-ember-data/addon/setup-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,6 @@ function initializeStore(application) {
}
}

function initializeStoreInjections(application) {
let inject = application.inject || application.injection;
inject.call(application, 'controller', 'store', 'service:store');
inject.call(application, 'route', 'store', 'service:store');
}

export default function setupContainer(application) {
initializeStoreInjections(application);
initializeStore(application);
}
3 changes: 0 additions & 3 deletions packages/-ember-data/app/initializers/ember-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import setupContainer from 'ember-data/setup-container';

/*
This code initializes EmberData in an Ember application.
It ensures that the `store` service is automatically injected
as the `store` property on all routes and controllers.
*/
export default {
name: 'ember-data',
Expand Down
37 changes: 0 additions & 37 deletions packages/-ember-data/tests/integration/injection-test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import Service from '@ember/service';

import { module, test } from 'qunit';

import { setupTest } from 'ember-qunit';

import Model from '@ember-data/model';

module('integration/injection factoryFor enabled', function (hooks) {
setupTest(hooks);
let store;
Expand Down Expand Up @@ -36,36 +32,3 @@ module('integration/injection factoryFor enabled', function (hooks) {
assert.equal(modelClass.modelName, 'super-villain', 'expected the factory itself to be returned');
});
});

module('integration/injection eager injections', function (hooks) {
setupTest(hooks);
let store;
let Apple = Service.extend();

hooks.beforeEach(function () {
let { owner } = this;

owner.register('model:foo', Model.extend());
owner.register('service:apple', Apple);
owner.inject('model:foo', 'apple', 'service:apple');

store = this.owner.lookup('service:store');
});

test('did inject', async function (assert) {
// TODO likely this test should instead test that we can use service injections
// on models (e.g. that owner is properly setup for it).
assert.expectDeprecation(
() => {
let foo = store.createRecord('foo');
let apple = foo.get('apple');
let appleService = this.owner.lookup('service:apple');

assert.ok(apple, `'model:foo' instance should have an 'apple' property`);
assert.ok(apple === appleService, `'model:foo.apple' should be the apple service`);
assert.ok(apple instanceof Apple, `'model:foo'.apple should be an instance of 'service:apple'`);
},
{ id: 'implicit-injections', count: 1, when: { ember: '>=3.27.0' } }
);
});
});
3 changes: 3 additions & 0 deletions packages/unpublished-fastboot-test-app/app/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

import { buildTree } from 'ember-simple-tree/utils/tree';

export default class IndexRoute extends Route {
@service store;

model() {
return this.store.findAll('person');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

export default Route.extend({
store: service(),
export default class PersonNewRoute extends Route {
@service store;

model() {
return this.store.createRecord('person');
},
});
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

export default Route.extend({
store: service(),

async model() {
performance.mark('start-data-generation');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

import { all } from 'rsvp';

export default Route.extend({
store: service(),

async model() {
performance.mark('start-data-generation');
const payload = await fetch('./fixtures/destroy.json').then((r) => r.json());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

export default Route.extend({
store: service(),

model() {
performance.mark('start-find-all');
return this.store.findAll('car', { reload: true }).then((cars) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import Route from '@ember/routing/route';
import { run } from '@ember/runloop';
import { inject as service } from '@ember/service';

export default Route.extend({
store: service(),

async model() {
performance.mark('start-data-generation');
const payload = await fetch('./fixtures/unload.json').then((r) => r.json());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

/**
* Measures the performance characteristics of pushing a large payload
* with tons of relationship data that will not be accessed.
*/
export default class UnusedRelationshipsRoute extends Route {
@service store;

async model() {
performance.mark('start-data-generation');

Expand Down

0 comments on commit e973920

Please sign in to comment.