From 20cc1fba06652adb672e0c70552b7dc96e1af81e Mon Sep 17 00:00:00 2001 From: ijlee2 Date: Fri, 25 Sep 2020 07:54:57 -0500 Subject: [PATCH 1/3] Updated how we present fetching data with Ember Data --- guides/release/routing/specifying-a-routes-model.md | 6 ++---- guides/v3.15.0/routing/specifying-a-routes-model.md | 6 ++---- guides/v3.16.0/routing/specifying-a-routes-model.md | 6 ++---- guides/v3.17.0/routing/specifying-a-routes-model.md | 6 ++---- guides/v3.18.0/routing/specifying-a-routes-model.md | 6 ++---- guides/v3.19.0/routing/specifying-a-routes-model.md | 6 ++---- guides/v3.20.0/routing/specifying-a-routes-model.md | 6 ++---- 7 files changed, 14 insertions(+), 28 deletions(-) diff --git a/guides/release/routing/specifying-a-routes-model.md b/guides/release/routing/specifying-a-routes-model.md index 414e250008..50b01e7d7e 100644 --- a/guides/release/routing/specifying-a-routes-model.md +++ b/guides/release/routing/specifying-a-routes-model.md @@ -125,20 +125,18 @@ identifier, instead): Ember Data is a powerful (but optional) library included by default in new Ember apps. In the next example, we will use Ember Data's [`findAll`](https://api.emberjs.com/ember-data/release/classes/Store/methods/findAll?anchor=findAll) method, which returns a Promise, and resolves with an array of [Ember Data records](../../models/). -_Note that Ember Data also has a feature called a [`Model`](https://api.emberjs.com/ember-data/release/classes/Model), but it's a separate concept from a route's [`model`](https://api.emberjs.com/ember/release/classes/Route/methods/model?anchor=model) hook._ - ```javascript {data-filename=app/routes/favorite-posts.js} import Route from '@ember/routing/route'; -import { inject as service } from '@ember/service'; export default class FavoritePostsRoute extends Route { - @service store; model() { return this.store.findAll('posts'); } } ``` +Note that Ember Data also has a feature called a [`Model`](https://api.emberjs.com/ember-data/release/classes/Model), but it's a separate concept from a route's [`model`](https://api.emberjs.com/ember/release/classes/Route/methods/model?anchor=model) hook. + ## Multiple Models What should you do if you need the `model` to return the results of multiple API requests? diff --git a/guides/v3.15.0/routing/specifying-a-routes-model.md b/guides/v3.15.0/routing/specifying-a-routes-model.md index 10dc39dcd6..f832889c79 100644 --- a/guides/v3.15.0/routing/specifying-a-routes-model.md +++ b/guides/v3.15.0/routing/specifying-a-routes-model.md @@ -125,20 +125,18 @@ identifier, instead): Ember Data is a powerful (but optional) library included by default in new Ember apps. In the next example, we will use Ember Data's [`findAll`](https://api.emberjs.com/ember-data/3.15/classes/Store/methods/findAll?anchor=findAll) method, which returns a Promise, and resolves with an array of [Ember Data records](../../models/). -_Note that Ember Data also has a feature called a [`Model`](https://api.emberjs.com/ember-data/3.15/classes/Model), but it's a separate concept from a route's [`model`](https://api.emberjs.com/ember/3.15/classes/Route/methods/model?anchor=model) hook._ - ```javascript {data-filename=app/routes/favorite-posts.js} import Route from '@ember/routing/route'; -import { inject as service } from '@ember/service'; export default class FavoritePostsRoute extends Route { - @service store; model() { return this.get('store').findAll('posts'); } } ``` +Note that Ember Data also has a feature called a [`Model`](https://api.emberjs.com/ember-data/3.15/classes/Model), but it's a separate concept from a route's [`model`](https://api.emberjs.com/ember/3.15/classes/Route/methods/model?anchor=model) hook. + ## Multiple Models What should you do if you need the `model` to return the results of multiple API requests? diff --git a/guides/v3.16.0/routing/specifying-a-routes-model.md b/guides/v3.16.0/routing/specifying-a-routes-model.md index cee8d1ee35..955f8139eb 100644 --- a/guides/v3.16.0/routing/specifying-a-routes-model.md +++ b/guides/v3.16.0/routing/specifying-a-routes-model.md @@ -125,20 +125,18 @@ identifier, instead): Ember Data is a powerful (but optional) library included by default in new Ember apps. In the next example, we will use Ember Data's [`findAll`](https://api.emberjs.com/ember-data/3.16/classes/Store/methods/findAll?anchor=findAll) method, which returns a Promise, and resolves with an array of [Ember Data records](../../models/). -_Note that Ember Data also has a feature called a [`Model`](https://api.emberjs.com/ember-data/3.16/classes/Model), but it's a separate concept from a route's [`model`](https://api.emberjs.com/ember/3.16/classes/Route/methods/model?anchor=model) hook._ - ```javascript {data-filename=app/routes/favorite-posts.js} import Route from '@ember/routing/route'; -import { inject as service } from '@ember/service'; export default class FavoritePostsRoute extends Route { - @service store; model() { return this.get('store').findAll('posts'); } } ``` +Note that Ember Data also has a feature called a [`Model`](https://api.emberjs.com/ember-data/3.16/classes/Model), but it's a separate concept from a route's [`model`](https://api.emberjs.com/ember/3.16/classes/Route/methods/model?anchor=model) hook. + ## Multiple Models What should you do if you need the `model` to return the results of multiple API requests? diff --git a/guides/v3.17.0/routing/specifying-a-routes-model.md b/guides/v3.17.0/routing/specifying-a-routes-model.md index 0869a528f4..85e45a5496 100644 --- a/guides/v3.17.0/routing/specifying-a-routes-model.md +++ b/guides/v3.17.0/routing/specifying-a-routes-model.md @@ -125,20 +125,18 @@ identifier, instead): Ember Data is a powerful (but optional) library included by default in new Ember apps. In the next example, we will use Ember Data's [`findAll`](https://api.emberjs.com/ember-data/3.17/classes/Store/methods/findAll?anchor=findAll) method, which returns a Promise, and resolves with an array of [Ember Data records](../../models/). -_Note that Ember Data also has a feature called a [`Model`](https://api.emberjs.com/ember-data/3.17/classes/Model), but it's a separate concept from a route's [`model`](https://api.emberjs.com/ember/3.17/classes/Route/methods/model?anchor=model) hook._ - ```javascript {data-filename=app/routes/favorite-posts.js} import Route from '@ember/routing/route'; -import { inject as service } from '@ember/service'; export default class FavoritePostsRoute extends Route { - @service store; model() { return this.store.findAll('posts'); } } ``` +Note that Ember Data also has a feature called a [`Model`](https://api.emberjs.com/ember-data/3.17/classes/Model), but it's a separate concept from a route's [`model`](https://api.emberjs.com/ember/3.17/classes/Route/methods/model?anchor=model) hook. + ## Multiple Models What should you do if you need the `model` to return the results of multiple API requests? diff --git a/guides/v3.18.0/routing/specifying-a-routes-model.md b/guides/v3.18.0/routing/specifying-a-routes-model.md index 852eccf04b..632e564585 100644 --- a/guides/v3.18.0/routing/specifying-a-routes-model.md +++ b/guides/v3.18.0/routing/specifying-a-routes-model.md @@ -125,20 +125,18 @@ identifier, instead): Ember Data is a powerful (but optional) library included by default in new Ember apps. In the next example, we will use Ember Data's [`findAll`](https://api.emberjs.com/ember-data/3.18/classes/Store/methods/findAll?anchor=findAll) method, which returns a Promise, and resolves with an array of [Ember Data records](../../models/). -_Note that Ember Data also has a feature called a [`Model`](https://api.emberjs.com/ember-data/3.18/classes/Model), but it's a separate concept from a route's [`model`](https://api.emberjs.com/ember/3.18/classes/Route/methods/model?anchor=model) hook._ - ```javascript {data-filename=app/routes/favorite-posts.js} import Route from '@ember/routing/route'; -import { inject as service } from '@ember/service'; export default class FavoritePostsRoute extends Route { - @service store; model() { return this.store.findAll('posts'); } } ``` +Note that Ember Data also has a feature called a [`Model`](https://api.emberjs.com/ember-data/3.18/classes/Model), but it's a separate concept from a route's [`model`](https://api.emberjs.com/ember/3.18/classes/Route/methods/model?anchor=model) hook. + ## Multiple Models What should you do if you need the `model` to return the results of multiple API requests? diff --git a/guides/v3.19.0/routing/specifying-a-routes-model.md b/guides/v3.19.0/routing/specifying-a-routes-model.md index f5a02d3c4a..4d1938daa2 100644 --- a/guides/v3.19.0/routing/specifying-a-routes-model.md +++ b/guides/v3.19.0/routing/specifying-a-routes-model.md @@ -125,20 +125,18 @@ identifier, instead): Ember Data is a powerful (but optional) library included by default in new Ember apps. In the next example, we will use Ember Data's [`findAll`](https://api.emberjs.com/ember-data/3.19/classes/Store/methods/findAll?anchor=findAll) method, which returns a Promise, and resolves with an array of [Ember Data records](../../models/). -_Note that Ember Data also has a feature called a [`Model`](https://api.emberjs.com/ember-data/3.19/classes/Model), but it's a separate concept from a route's [`model`](https://api.emberjs.com/ember/3.19/classes/Route/methods/model?anchor=model) hook._ - ```javascript {data-filename=app/routes/favorite-posts.js} import Route from '@ember/routing/route'; -import { inject as service } from '@ember/service'; export default class FavoritePostsRoute extends Route { - @service store; model() { return this.store.findAll('posts'); } } ``` +Note that Ember Data also has a feature called a [`Model`](https://api.emberjs.com/ember-data/3.19/classes/Model), but it's a separate concept from a route's [`model`](https://api.emberjs.com/ember/3.19/classes/Route/methods/model?anchor=model) hook. + ## Multiple Models What should you do if you need the `model` to return the results of multiple API requests? diff --git a/guides/v3.20.0/routing/specifying-a-routes-model.md b/guides/v3.20.0/routing/specifying-a-routes-model.md index 7e6f4816be..0ffa1bb970 100644 --- a/guides/v3.20.0/routing/specifying-a-routes-model.md +++ b/guides/v3.20.0/routing/specifying-a-routes-model.md @@ -125,20 +125,18 @@ identifier, instead): Ember Data is a powerful (but optional) library included by default in new Ember apps. In the next example, we will use Ember Data's [`findAll`](https://api.emberjs.com/ember-data/3.20/classes/Store/methods/findAll?anchor=findAll) method, which returns a Promise, and resolves with an array of [Ember Data records](../../models/). -_Note that Ember Data also has a feature called a [`Model`](https://api.emberjs.com/ember-data/3.20/classes/Model), but it's a separate concept from a route's [`model`](https://api.emberjs.com/ember/3.20/classes/Route/methods/model?anchor=model) hook._ - ```javascript {data-filename=app/routes/favorite-posts.js} import Route from '@ember/routing/route'; -import { inject as service } from '@ember/service'; export default class FavoritePostsRoute extends Route { - @service store; model() { return this.store.findAll('posts'); } } ``` +Note that Ember Data also has a feature called a [`Model`](https://api.emberjs.com/ember-data/3.20/classes/Model), but it's a separate concept from a route's [`model`](https://api.emberjs.com/ember/3.20/classes/Route/methods/model?anchor=model) hook. + ## Multiple Models What should you do if you need the `model` to return the results of multiple API requests? From 3398c1a7efded409adebee6bb6b6b0090aa1abda Mon Sep 17 00:00:00 2001 From: ijlee2 Date: Fri, 25 Sep 2020 08:10:34 -0500 Subject: [PATCH 2/3] Explained when a developer needs to inject the store service --- guides/release/models/index.md | 6 ++++-- guides/v3.15.0/models/index.md | 6 ++++-- guides/v3.16.0/models/index.md | 6 ++++-- guides/v3.17.0/models/index.md | 6 ++++-- guides/v3.18.0/models/index.md | 6 ++++-- guides/v3.19.0/models/index.md | 6 ++++-- guides/v3.20.0/models/index.md | 6 ++++-- 7 files changed, 28 insertions(+), 14 deletions(-) diff --git a/guides/release/models/index.md b/guides/release/models/index.md index 585fa36bc5..a01db93941 100644 --- a/guides/release/models/index.md +++ b/guides/release/models/index.md @@ -186,8 +186,10 @@ first ask the store for it.
Zoey says...
- Ember Data injects the store service in every route and controller, - so you can access it as `this.store`! + Ember Data injects the store service to every route and controller + so that you can immediately write this.store! + If you want to access the store in a component or another service, + you will need to inject the store service.
diff --git a/guides/v3.15.0/models/index.md b/guides/v3.15.0/models/index.md index e904c85a17..4b2e591c74 100644 --- a/guides/v3.15.0/models/index.md +++ b/guides/v3.15.0/models/index.md @@ -186,8 +186,10 @@ first ask the store for it.
Zoey says...
- Ember Data injects the store service in every route and controller, - so you can access it as `this.store`! + Ember Data injects the store service to every route and controller + so that you can immediately write this.store! + If you want to access the store in a component or another service, + you will need to inject the store service.
diff --git a/guides/v3.16.0/models/index.md b/guides/v3.16.0/models/index.md index e904c85a17..4b2e591c74 100644 --- a/guides/v3.16.0/models/index.md +++ b/guides/v3.16.0/models/index.md @@ -186,8 +186,10 @@ first ask the store for it.
Zoey says...
- Ember Data injects the store service in every route and controller, - so you can access it as `this.store`! + Ember Data injects the store service to every route and controller + so that you can immediately write this.store! + If you want to access the store in a component or another service, + you will need to inject the store service.
diff --git a/guides/v3.17.0/models/index.md b/guides/v3.17.0/models/index.md index e904c85a17..4b2e591c74 100644 --- a/guides/v3.17.0/models/index.md +++ b/guides/v3.17.0/models/index.md @@ -186,8 +186,10 @@ first ask the store for it.
Zoey says...
- Ember Data injects the store service in every route and controller, - so you can access it as `this.store`! + Ember Data injects the store service to every route and controller + so that you can immediately write this.store! + If you want to access the store in a component or another service, + you will need to inject the store service.
diff --git a/guides/v3.18.0/models/index.md b/guides/v3.18.0/models/index.md index e904c85a17..4b2e591c74 100644 --- a/guides/v3.18.0/models/index.md +++ b/guides/v3.18.0/models/index.md @@ -186,8 +186,10 @@ first ask the store for it.
Zoey says...
- Ember Data injects the store service in every route and controller, - so you can access it as `this.store`! + Ember Data injects the store service to every route and controller + so that you can immediately write this.store! + If you want to access the store in a component or another service, + you will need to inject the store service.
diff --git a/guides/v3.19.0/models/index.md b/guides/v3.19.0/models/index.md index e904c85a17..4b2e591c74 100644 --- a/guides/v3.19.0/models/index.md +++ b/guides/v3.19.0/models/index.md @@ -186,8 +186,10 @@ first ask the store for it.
Zoey says...
- Ember Data injects the store service in every route and controller, - so you can access it as `this.store`! + Ember Data injects the store service to every route and controller + so that you can immediately write this.store! + If you want to access the store in a component or another service, + you will need to inject the store service.
diff --git a/guides/v3.20.0/models/index.md b/guides/v3.20.0/models/index.md index e904c85a17..4b2e591c74 100644 --- a/guides/v3.20.0/models/index.md +++ b/guides/v3.20.0/models/index.md @@ -186,8 +186,10 @@ first ask the store for it.
Zoey says...
- Ember Data injects the store service in every route and controller, - so you can access it as `this.store`! + Ember Data injects the store service to every route and controller + so that you can immediately write this.store! + If you want to access the store in a component or another service, + you will need to inject the store service.
From f0858342c55688bfebbe67014f44ffd1d50c18d9 Mon Sep 17 00:00:00 2001 From: ijlee2 Date: Mon, 28 Sep 2020 16:38:40 -0500 Subject: [PATCH 3/3] Reverted removal of explicit store injection --- guides/release/routing/specifying-a-routes-model.md | 3 +++ guides/v3.15.0/routing/specifying-a-routes-model.md | 3 +++ guides/v3.16.0/routing/specifying-a-routes-model.md | 3 +++ guides/v3.17.0/routing/specifying-a-routes-model.md | 3 +++ guides/v3.18.0/routing/specifying-a-routes-model.md | 3 +++ guides/v3.19.0/routing/specifying-a-routes-model.md | 3 +++ guides/v3.20.0/routing/specifying-a-routes-model.md | 3 +++ 7 files changed, 21 insertions(+) diff --git a/guides/release/routing/specifying-a-routes-model.md b/guides/release/routing/specifying-a-routes-model.md index 50b01e7d7e..98ecd9724b 100644 --- a/guides/release/routing/specifying-a-routes-model.md +++ b/guides/release/routing/specifying-a-routes-model.md @@ -17,8 +17,11 @@ Here's an example of a model hook in use within a route: ```javascript {data-filename=app/routes/favorite-posts.js} import Route from '@ember/routing/route'; +import { inject as service } from '@ember/service'; export default class FavoritePostsRoute extends Route { + @service store; + model() { console.log('The model hook just ran!'); return 'Hello Ember!'; diff --git a/guides/v3.15.0/routing/specifying-a-routes-model.md b/guides/v3.15.0/routing/specifying-a-routes-model.md index f832889c79..6fc4b1dadf 100644 --- a/guides/v3.15.0/routing/specifying-a-routes-model.md +++ b/guides/v3.15.0/routing/specifying-a-routes-model.md @@ -17,8 +17,11 @@ Here's an example of a model hook in use within a route: ```javascript {data-filename=app/routes/favorite-posts.js} import Route from '@ember/routing/route'; +import { inject as service } from '@ember/service'; export default class FavoritePostsRoute extends Route { + @service store; + model() { console.log('The model hook just ran!'); return 'Hello Ember!'; diff --git a/guides/v3.16.0/routing/specifying-a-routes-model.md b/guides/v3.16.0/routing/specifying-a-routes-model.md index 955f8139eb..ca413163ee 100644 --- a/guides/v3.16.0/routing/specifying-a-routes-model.md +++ b/guides/v3.16.0/routing/specifying-a-routes-model.md @@ -17,8 +17,11 @@ Here's an example of a model hook in use within a route: ```javascript {data-filename=app/routes/favorite-posts.js} import Route from '@ember/routing/route'; +import { inject as service } from '@ember/service'; export default class FavoritePostsRoute extends Route { + @service store; + model() { console.log('The model hook just ran!'); return 'Hello Ember!'; diff --git a/guides/v3.17.0/routing/specifying-a-routes-model.md b/guides/v3.17.0/routing/specifying-a-routes-model.md index 85e45a5496..e6fe650db8 100644 --- a/guides/v3.17.0/routing/specifying-a-routes-model.md +++ b/guides/v3.17.0/routing/specifying-a-routes-model.md @@ -17,8 +17,11 @@ Here's an example of a model hook in use within a route: ```javascript {data-filename=app/routes/favorite-posts.js} import Route from '@ember/routing/route'; +import { inject as service } from '@ember/service'; export default class FavoritePostsRoute extends Route { + @service store; + model() { console.log('The model hook just ran!'); return 'Hello Ember!'; diff --git a/guides/v3.18.0/routing/specifying-a-routes-model.md b/guides/v3.18.0/routing/specifying-a-routes-model.md index 632e564585..2a8dc9ce65 100644 --- a/guides/v3.18.0/routing/specifying-a-routes-model.md +++ b/guides/v3.18.0/routing/specifying-a-routes-model.md @@ -17,8 +17,11 @@ Here's an example of a model hook in use within a route: ```javascript {data-filename=app/routes/favorite-posts.js} import Route from '@ember/routing/route'; +import { inject as service } from '@ember/service'; export default class FavoritePostsRoute extends Route { + @service store; + model() { console.log('The model hook just ran!'); return 'Hello Ember!'; diff --git a/guides/v3.19.0/routing/specifying-a-routes-model.md b/guides/v3.19.0/routing/specifying-a-routes-model.md index 4d1938daa2..6ea40cb1d5 100644 --- a/guides/v3.19.0/routing/specifying-a-routes-model.md +++ b/guides/v3.19.0/routing/specifying-a-routes-model.md @@ -17,8 +17,11 @@ Here's an example of a model hook in use within a route: ```javascript {data-filename=app/routes/favorite-posts.js} import Route from '@ember/routing/route'; +import { inject as service } from '@ember/service'; export default class FavoritePostsRoute extends Route { + @service store; + model() { console.log('The model hook just ran!'); return 'Hello Ember!'; diff --git a/guides/v3.20.0/routing/specifying-a-routes-model.md b/guides/v3.20.0/routing/specifying-a-routes-model.md index 0ffa1bb970..74c500d60f 100644 --- a/guides/v3.20.0/routing/specifying-a-routes-model.md +++ b/guides/v3.20.0/routing/specifying-a-routes-model.md @@ -17,8 +17,11 @@ Here's an example of a model hook in use within a route: ```javascript {data-filename=app/routes/favorite-posts.js} import Route from '@ember/routing/route'; +import { inject as service } from '@ember/service'; export default class FavoritePostsRoute extends Route { + @service store; + model() { console.log('The model hook just ran!'); return 'Hello Ember!';