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

Provide service export from @ember/service in favour of inject #19776

Merged
merged 1 commit into from
Oct 22, 2021
Merged
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
4 changes: 2 additions & 2 deletions packages/@ember/-internals/glimmer/lib/components/-link-to.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { EMBER_MODERNIZED_BUILT_IN_COMPONENTS } from '@ember/canary-features';
import { assert, deprecate, runInDebug, warn } from '@ember/debug';
import { EngineInstance, getEngineParent } from '@ember/engine';
import { flaggedInstrument } from '@ember/instrumentation';
import { inject as injectService } from '@ember/service';
import { service } from '@ember/service';
import { DEBUG } from '@glimmer/env';
import EmberComponent from '../component';
import { HAS_BLOCK } from '../component-managers/curly';
Expand Down Expand Up @@ -506,7 +506,7 @@ const LinkComponent = EmberComponent.extend({
this.on(eventName, this, this._invoke);
},

_routing: injectService('-routing'),
_routing: service('-routing'),
_currentRoute: alias('_routing.currentRouteName'),
_currentRouterState: alias('_routing.currentState'),
_targetRouterState: alias('_routing.targetState'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { assert, debugFreeze, deprecate, warn } from '@ember/debug';
import { EngineInstance, getEngineParent } from '@ember/engine';
import { flaggedInstrument } from '@ember/instrumentation';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import { service } from '@ember/service';
import { DEBUG } from '@glimmer/env';
import { Maybe, Option } from '@glimmer/interfaces';
import { consumeTag, createCache, getValue, tagFor, untrack } from '@glimmer/validator';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@
```javascript
import Component from '@glimmer/component';
import { inject as service } from '@ember/service';
import { service } from '@ember/service';
export default class SomeComponent extends Component {
@service myAnimations;
Expand All @@ -319,7 +319,7 @@
```javascript
import Component from '@glimmer/component';
import { inject as service } from '@ember/service';
import { service } from '@ember/service';
export default class SomeComponent extends Component {
@service myAnimations;
Expand Down
2 changes: 1 addition & 1 deletion packages/@ember/-internals/glimmer/lib/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ let Helper = FrameworkObject.extend({
```app/helpers/current-user-email.js
import Helper from '@ember/component/helper'
import { inject as service } from '@ember/service'
import { service } from '@ember/service'
import { observer } from '@ember/object'
export default Helper.extend({
Expand Down
2 changes: 1 addition & 1 deletion packages/@ember/-internals/glimmer/lib/helpers/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export const ACTIONS = new _WeakSet();
```app/controllers/application.js
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
import { service } from '@ember/service';
export default class extends Controller {
@service someService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { moduleFor, ApplicationTestCase } from 'internal-test-helpers';
import Controller from '@ember/controller';
import Service, { inject as injectService } from '@ember/service';
import Service, { service } from '@ember/service';
import { Helper, helper } from '@ember/-internals/glimmer';

moduleFor(
Expand Down Expand Up @@ -92,7 +92,7 @@ moduleFor(
this.add(
'helper:full-name',
Helper.extend({
nameBuilder: injectService('name-builder'),
nameBuilder: service('name-builder'),
compute() {
this.get('nameBuilder').build();
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { moduleFor, ApplicationTestCase, strip, runTask } from 'internal-test-helpers';

import { ENV } from '@ember/-internals/environment';
import Service, { inject as injectService } from '@ember/service';
import Service, { service } from '@ember/service';
import { Component, Helper } from '@ember/-internals/glimmer';
import { expect } from '@glimmer/util';

Expand Down Expand Up @@ -59,7 +59,7 @@ moduleFor(
this.add(
'helper:hot-reload',
Helper.extend({
reloader: injectService(),
reloader: service(),

init() {
this._super(...arguments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { run } from '@ember/runloop';
import { DEBUG } from '@glimmer/env';
import { alias, set, get, observer, on, computed, tracked } from '@ember/-internals/metal';
import Service, { inject as injectService } from '@ember/service';
import Service, { service } from '@ember/service';
import { Object as EmberObject, A as emberA } from '@ember/-internals/runtime';

import { Component, compile, htmlSafe } from '../../utils/helpers';
Expand Down Expand Up @@ -2855,21 +2855,21 @@ moduleFor(
}

['@test services can be injected into components']() {
let service;
let serviceInstance;
this.registerService(
'name',
Service.extend({
init() {
this._super(...arguments);
service = this;
serviceInstance = this;
},
last: 'Jackson',
})
);

this.registerComponent('foo-bar', {
ComponentClass: Component.extend({
name: injectService(),
name: service(),
}),
template: '{{this.name.last}}',
});
Expand All @@ -2883,13 +2883,13 @@ moduleFor(
this.assertText('Jackson');

runTask(() => {
service.set('last', 'McGuffey');
serviceInstance.set('last', 'McGuffey');
});

this.assertText('McGuffey');

runTask(() => {
service.set('last', 'Jackson');
serviceInstance.set('last', 'Jackson');
});

this.assertText('Jackson');
Expand All @@ -2898,7 +2898,7 @@ moduleFor(
['@test injecting an unknown service raises an exception']() {
this.registerComponent('foo-bar', {
ComponentClass: Component.extend({
missingService: injectService(),
missingService: service(),
}),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { RenderingTestCase, moduleFor, runTask } from 'internal-test-helpers';
import { tracked, set } from '@ember/-internals/metal';
import { setOwner } from '@ember/-internals/owner';
import { EMBER_GLIMMER_HELPER_MANAGER } from '@ember/canary-features';
import Service, { inject as service } from '@ember/service';
import Service, { service } from '@ember/service';
import { registerDestructor } from '@glimmer/destroyable';
import { backtrackingMessageFor } from '../../utils/debug-stack';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Helper, helper, Component as EmberComponent } from '@ember/-internals/g
import { tracked, set } from '@ember/-internals/metal';
import { getOwner } from '@ember/-internals/owner';
import { EMBER_GLIMMER_INVOKE_HELPER, EMBER_GLIMMER_HELPER_MANAGER } from '@ember/canary-features';
import Service, { inject as service } from '@ember/service';
import Service, { service } from '@ember/service';
import { DEBUG } from '@glimmer/env';
import { getValue } from '@glimmer/validator';
import { destroy, isDestroyed, registerDestructor } from '@glimmer/destroyable';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
nativeDescDecorator as descriptor,
notifyPropertyChange,
} from '@ember/-internals/metal';
import Service, { inject } from '@ember/service';
import Service, { service } from '@ember/service';
import { moduleFor, RenderingTestCase, strip, runTask } from 'internal-test-helpers';

import { backtrackingMessageFor } from '../../utils/debug-stack';
Expand Down Expand Up @@ -293,7 +293,7 @@ moduleFor(

this.registerComponent('person', {
ComponentClass: Component.extend({
currentUser: inject('current-user'),
currentUser: service('current-user'),
}),

template: strip`
Expand Down
20 changes: 10 additions & 10 deletions packages/@ember/-internals/routing/lib/services/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function cleanURL(url: string, rootURL: string) {
```app/components/example.js
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import { service } from '@ember/service';
export default class ExampleComponent extends Component {
@service router;
Expand Down Expand Up @@ -85,7 +85,7 @@ export default class RouterService extends Service {
```app/components/example.js
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import { service } from '@ember/service';
export default class extends Component {
@service router;
Expand Down Expand Up @@ -184,7 +184,7 @@ export default class RouterService extends Service {
```app/components/copy-link.js
import Component from '@glimmer/component';
import { inject as service } from '@ember/service';
import { service } from '@ember/service';
import { action } from '@ember/object';
export default class CopyLinkComponent extends Component {
Expand All @@ -211,7 +211,7 @@ export default class RouterService extends Service {
```app/components/copy-link.js
import Component from '@glimmer/component';
import { inject as service } from '@ember/service';
import { service } from '@ember/service';
import { action } from '@ember/object';
export default class CopyLinkComponent extends Component {
Expand Down Expand Up @@ -254,7 +254,7 @@ export default class RouterService extends Service {
```app/components/posts.js
import Component from '@glimmer/component';
import { inject as service } from '@ember/service';
import { service } from '@ember/service';
export default class extends Component {
@service router;
Expand All @@ -270,7 +270,7 @@ export default class RouterService extends Service {
```app/components/posts.js
import Component from '@glimmer/component';
import { inject as service } from '@ember/service';
import { service } from '@ember/service';
export default class extends Component {
@service router;
Expand Down Expand Up @@ -354,7 +354,7 @@ export default class RouterService extends Service {
```
import Component from '@ember/component';
import { inject as service } from '@ember/service';
import { service } from '@ember/service';
export default class extends Component {
@service router;
Expand Down Expand Up @@ -414,7 +414,7 @@ export default class RouterService extends Service {
```app/routes/contact-form.js
import Route from '@ember/routing';
import { inject as service } from '@ember/service';
import { service } from '@ember/service';
export default class extends Route {
@service router;
Expand Down Expand Up @@ -448,7 +448,7 @@ export default class RouterService extends Service {
```app/routes/contact-form.js
import Route from '@ember/routing';
import { inject as service } from '@ember/service';
import { service } from '@ember/service';
export default class extends Route {
@service router;
Expand Down Expand Up @@ -656,7 +656,7 @@ RouterService.reopen(Evented, {
Usage example:
```app/components/header.js
import Component from '@glimmer/component';
import { inject as service } from '@ember/service';
import { service } from '@ember/service';
import { notEmpty } from '@ember/object/computed';
export default class extends Component {
Expand Down
2 changes: 1 addition & 1 deletion packages/@ember/-internals/routing/lib/system/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@ class Route extends EmberObject.extend(ActionHandler, Evented) implements IRoute
```app/routes/application.js
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { service } from '@ember/service';
export default class ApplicationRoute extends Route {
@service router
Expand Down
2 changes: 1 addition & 1 deletion packages/@ember/-internals/routing/lib/system/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1387,7 +1387,7 @@ class EmberRouter extends EmberObject.extend(Evented) implements Evented {
```javascript
import config from './config/environment';
import EmberRouter from '@ember/routing/router';
import { inject as service } from '@ember/service';
import { service } from '@ember/service';
let Router = EmberRouter.extend({
location: config.locationType,
Expand Down
4 changes: 2 additions & 2 deletions packages/@ember/-internals/routing/tests/system/route_test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { setOwner } from '@ember/-internals/owner';
import { runDestroy, buildOwner, moduleFor, AbstractTestCase } from 'internal-test-helpers';
import Service, { inject as injectService } from '@ember/service';
import Service, { service } from '@ember/service';
import { Object as EmberObject } from '@ember/-internals/runtime';
import EmberRoute from '../../lib/system/route';
import { defineProperty } from '../../../metal';
Expand Down Expand Up @@ -321,7 +321,7 @@ moduleFor(
owner.register(
'route:application',
EmberRoute.extend({
authService: injectService('auth'),
authService: service('auth'),
})
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getFactoryFor, Registry } from '@ember/-internals/container';
import { getOwner, setOwner } from '@ember/-internals/owner';
import { computed, Mixin, observer, addObserver, alias } from '@ember/-internals/metal';
import Service, { inject as service } from '@ember/service';
import Service, { service } from '@ember/service';
import { DEBUG } from '@glimmer/env';
import EmberObject from '../../../lib/system/object';
import { buildOwner, moduleFor, AbstractTestCase } from 'internal-test-helpers';
Expand Down
2 changes: 1 addition & 1 deletion packages/@ember/application/lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,7 @@ const Application = Engine.extend({
```app/routes/post.js
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { service } from '@ember/service';
// An example of how the (hypothetical) service is used in routes.
Expand Down
8 changes: 4 additions & 4 deletions packages/@ember/application/tests/visit_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
ApplicationTestCase,
runTask,
} from 'internal-test-helpers';
import { inject as injectService } from '@ember/service';
import { service } from '@ember/service';
import { Object as EmberObject, RSVP, onerrorDefault } from '@ember/-internals/runtime';
import { later } from '@ember/runloop';
import Application from '@ember/application';
Expand Down Expand Up @@ -683,8 +683,8 @@ moduleFor(
Component.extend({
tagName: 'x-foo',

isolatedCounter: injectService(),
sharedCounter: injectService(),
isolatedCounter: service(),
sharedCounter: service(),

init() {
this._super();
Expand Down Expand Up @@ -713,7 +713,7 @@ moduleFor(
this.add(
'component:x-bar',
Component.extend({
counter: injectService('sharedCounter'),
counter: service('sharedCounter'),

actions: {
incrementCounter() {
Expand Down
4 changes: 2 additions & 2 deletions packages/@ember/controller/tests/controller_test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Controller, { inject as injectController } from '@ember/controller';
import Service, { inject as injectService } from '@ember/service';
import Service, { service } from '@ember/service';
import { Object as EmberObject } from '@ember/-internals/runtime';
import { Mixin, get } from '@ember/-internals/metal';
import { setOwner } from '@ember/-internals/owner';
Expand Down Expand Up @@ -265,7 +265,7 @@ moduleFor(
owner.register(
'controller:application',
Controller.extend({
authService: injectService('auth'),
authService: service('auth'),
})
);

Expand Down
1 change: 1 addition & 0 deletions packages/@ember/service/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export function inject(name?: string): any;
export function service(name?: string): any;
declare let Service: any;
export default Service;
Loading