Skip to content

Conversation

chrisrng
Copy link
Member

First draft in tackling #34

rendered


Controllers behave like a specialized type of Component that is rendered by
the router when entering a Route.
[Controllers](https://emberjs.com/api/ember/release/classes/Controller) are a routable object that is used to decorate the model returned by the router when entering a Route. A Controller is usually paired with an individual Route of the same name.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you make this singular? A controller is a routable object...

[Controllers](https://emberjs.com/api/ember/release/classes/Controller) are a routable object that is used to decorate the model returned by the router when entering a Route. A Controller is usually paired with an individual Route of the same name.

The controller receives a single property from the Route – `model` – which is
the return value of the Route's `model()` method.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to mention these two lines above somewhere explicitly

Copy link
Member Author

@chrisrng chrisrng May 22, 2018

Choose a reason for hiding this comment

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

This is what I mean by routable :) but yes agree I'll bring this back in

</div>
Yes! Controllers are still an integral part of an Ember application architecture, and generated by the framework even if you don't declare a Controller module explicitly.

###### When should we create a Controller?
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the content of this section be rolled into "When and where to use controllers"?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thoughts on leaving this here? I think it might be quoted a bit and wanted it in the same place for people to see

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with either

@jenweber
Copy link
Contributor

Thank you @chrisrng! I added some comments. I really like the the "where & when" section and the places you've simplified some of the language.

I am curious about this sentence:

A controller is a routable object that is used to decorate the model returned by the router when entering a Route.

I don't know enough about controllers myself to know if this is accurate. Can you tell me more about it?

@mansona
Copy link
Member

mansona commented May 22, 2018

@jenweber I quite like @chrisrng's line about decorating a model, but I would be a tiny bit concerned about the wording 🤔

is a routable object that is used to decorate the model

that suggests that its only purpose is to decorate the model, which is not true. You also can make use of controllers if you're not using models in some cases, even if it's not recommended 😂

@chrisrng how about:

A controller is a routable object that can be used to decorate the model returned by the router when entering a Route.

or

A controller is a routable object that is mostly used to decorate the model returned by the router when entering a Route.

Again this might need a look over from someone who knows more about controllers than I do 😂

@chrisrng
Copy link
Member Author

chrisrng commented May 22, 2018

@jenweber @mansona

updated rendered

@jenweber thanks for the review! I added an example to explain that sentence more (see below).
@mansona also thanks for the suggestion! I incorporated the second one in the text below.

Rewrote the first paragraph into the following:

What is a Controller?

A Controller is routable object which receives a single property from the Route – model – which is the return value of the Route's model() method.

The model is passed from the Route to the Controller by default using the setupController function. The Controller is then often used to decorate the model with display properties such as retrieving the full name from a name model.

A Controller is usually paired with an individual Route of the same name.

@chrisrng
Copy link
Member Author

One more update to adhere to Contributing guide (fixed links and commit message)

rendered

@jenweber
Copy link
Contributor

Thank you for the edits! I want to get one more person to sign off on the "routable object" definition and we'll be good to merge :D I ran the app locally and everything renders great.

@mansona
Copy link
Member

mansona commented May 23, 2018

@jenweber I'm 👍 with the introduction section if that's what you mean? 😂 but as it's quite an important section it might be worth asking others too 😖

@jenweber
Copy link
Contributor

@mansona I have received one comment that "routable" is incorrect, and a few other people saying it's fine, so I asked in #dev-ember and didn't hear back yet.

I'm going to merge and if I get more clarification, we can correct it. It's related to the route, so it's routable, ok :P

@jenweber jenweber merged commit eb6d64c into ember-learn:master May 24, 2018
@jenweber
Copy link
Contributor

Merged, thank you @chrisrng!

jenweber pushed a commit that referenced this pull request Jun 3, 2018
* adding Chris Ng's controllers index work into 3.2 #34

* propogate changes from 3.1 PR #46
@chrisrng chrisrng deleted the chris/controller-index branch January 21, 2019 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants