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

Updated how we describe injecting Ember Data store #1541

Merged
merged 3 commits into from
Oct 16, 2020
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
6 changes: 4 additions & 2 deletions guides/release/models/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,10 @@ first ask the store for it.
<div class="cta-note-body">
<div class="cta-note-heading">Zoey says...</div>
<div class="cta-note-message">
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 <code>this.store</code>!
If you want to access the store in a component or another service,
you will need to <a href="../services/#toc_accessing-services">inject</a> the store service.
</div>
</div>
<img src="/images/mascots/zoey.png" role="presentation" alt="">
Expand Down
9 changes: 5 additions & 4 deletions guides/release/routing/specifying-a-routes-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!';
Expand Down Expand Up @@ -125,20 +128,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._
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the reader hasn't seen the code yet, I thought it'd be better to move this paragraph (an afterthought about Model vs. model()) after we present the code.


```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?
Expand Down
6 changes: 4 additions & 2 deletions guides/v3.15.0/models/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,10 @@ first ask the store for it.
<div class="cta-note-body">
<div class="cta-note-heading">Zoey says...</div>
<div class="cta-note-message">
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 <code>this.store</code>!
If you want to access the store in a component or another service,
you will need to <a href="../services/#toc_accessing-services">inject</a> the store service.
</div>
</div>
<img src="/images/mascots/zoey.png" role="presentation" alt="">
Expand Down
9 changes: 5 additions & 4 deletions guides/v3.15.0/routing/specifying-a-routes-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!';
Expand Down Expand Up @@ -125,20 +128,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?
Expand Down
6 changes: 4 additions & 2 deletions guides/v3.16.0/models/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,10 @@ first ask the store for it.
<div class="cta-note-body">
<div class="cta-note-heading">Zoey says...</div>
<div class="cta-note-message">
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 <code>this.store</code>!
If you want to access the store in a component or another service,
you will need to <a href="../services/#toc_accessing-services">inject</a> the store service.
</div>
</div>
<img src="/images/mascots/zoey.png" role="presentation" alt="">
Expand Down
9 changes: 5 additions & 4 deletions guides/v3.16.0/routing/specifying-a-routes-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!';
Expand Down Expand Up @@ -125,20 +128,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?
Expand Down
6 changes: 4 additions & 2 deletions guides/v3.17.0/models/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,10 @@ first ask the store for it.
<div class="cta-note-body">
<div class="cta-note-heading">Zoey says...</div>
<div class="cta-note-message">
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 <code>this.store</code>!
If you want to access the store in a component or another service,
you will need to <a href="../services/#toc_accessing-services">inject</a> the store service.
</div>
</div>
<img src="/images/mascots/zoey.png" role="presentation" alt="">
Expand Down
9 changes: 5 additions & 4 deletions guides/v3.17.0/routing/specifying-a-routes-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!';
Expand Down Expand Up @@ -125,20 +128,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?
Expand Down
6 changes: 4 additions & 2 deletions guides/v3.18.0/models/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,10 @@ first ask the store for it.
<div class="cta-note-body">
<div class="cta-note-heading">Zoey says...</div>
<div class="cta-note-message">
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 <code>this.store</code>!
If you want to access the store in a component or another service,
you will need to <a href="../services/#toc_accessing-services">inject</a> the store service.
</div>
</div>
<img src="/images/mascots/zoey.png" role="presentation" alt="">
Expand Down
9 changes: 5 additions & 4 deletions guides/v3.18.0/routing/specifying-a-routes-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!';
Expand Down Expand Up @@ -125,20 +128,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?
Expand Down
6 changes: 4 additions & 2 deletions guides/v3.19.0/models/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,10 @@ first ask the store for it.
<div class="cta-note-body">
<div class="cta-note-heading">Zoey says...</div>
<div class="cta-note-message">
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 <code>this.store</code>!
If you want to access the store in a component or another service,
you will need to <a href="../services/#toc_accessing-services">inject</a> the store service.
</div>
</div>
<img src="/images/mascots/zoey.png" role="presentation" alt="">
Expand Down
9 changes: 5 additions & 4 deletions guides/v3.19.0/routing/specifying-a-routes-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!';
Expand Down Expand Up @@ -125,20 +128,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?
Expand Down
6 changes: 4 additions & 2 deletions guides/v3.20.0/models/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,10 @@ first ask the store for it.
<div class="cta-note-body">
<div class="cta-note-heading">Zoey says...</div>
<div class="cta-note-message">
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 <code>this.store</code>!
If you want to access the store in a component or another service,
you will need to <a href="../services/#toc_accessing-services">inject</a> the store service.
</div>
</div>
<img src="/images/mascots/zoey.png" role="presentation" alt="">
Expand Down
9 changes: 5 additions & 4 deletions guides/v3.20.0/routing/specifying-a-routes-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!';
Expand Down Expand Up @@ -125,20 +128,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?
Expand Down