@@ -103,7 +103,7 @@ $(window).on('resize', () => {
103103 componentsToNotify .forEach (c => c .windowDidResize ());
104104});
105105
106- export default Component . extend ( {
106+ export default class ResizableComponent extends Component {
107107 init () {
108108 componentsToNotify .push (this );
109109 },
@@ -120,7 +120,7 @@ export default Component.extend({
120120 }
121121 }
122122 }
123- });
123+ }
124124```
125125
126126In this approach, we set up an event listener on the window even if the
@@ -148,7 +148,7 @@ function setupListener() {
148148 });
149149}
150150
151- export default Component . extend ( {
151+ export default class ResizableComponent extends Component {
152152 didInsertElement () {
153153 if (! didSetupListener) { setupListener (); }
154154 componentsToNotify .push (this );
@@ -166,7 +166,7 @@ export default Component.extend({
166166 }
167167 }
168168 }
169- });
169+ }
170170```
171171
172172This lazy approach moves setup to the first time the component is used,
@@ -425,27 +425,26 @@ doesn't have FastBoot installed. In that case, if your addon tries to
425425inject the ` fastboot ` service, they'll get an exception saying the
426426` fastboot ` service cannot be found.
427427
428- Instead, you can write a computed property that uses the low-level
428+ Instead, you can write a getter that uses the low-level
429429` getOwner ` functionality to lookup the ` fastboot ` service directly:
430430
431431``` js
432432import Service from ' @ember/service' ;
433- import { computed } from ' @ember/object' ;
434433import { getOwner } from ' @ember/application' ;
435434
436- export default Service . extend ( {
435+ export default class SomeService extends Service {
437436 doSomething () {
438- let fastboot = this .get ( ' fastboot' ) ;
437+ let fastboot = this .fastboot ;
439438 if (! fastboot) { return ; }
440439 // do something that requires FastBoot
441440 },
442441
443- fastboot : computed ( function () {
442+ get fastboot () {
444443 let owner = getOwner (this );
445444
446445 return owner .lookup (' service:fastboot' );
447- })
448- });
446+ }
447+ }
449448```
450449
451450## Examples
0 commit comments