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

Narrow scope, specify route generation #7

Closed
wants to merge 2 commits into from
Closed
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
29 changes: 3 additions & 26 deletions text/0000-controller-migration-path.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,7 @@

_The goal is for components to make up the entirety of the view layer_.

- Requires:
- [RFC 496: Handlebars Strict Mode](https://github.com/emberjs/rfcs/pull/496)
- [RFC 454: SFC & Template Import Primitives](https://github.com/emberjs/rfcs/pull/454)
- [RFC 380: Add queryParams to the router service](https://github.com/emberjs/rfcs/pull/380)

- Provide alternative APIs that encompass existing behavior currently implemented by controllers.
1. query params
2. passing state and handling actions to/from the route, loading, and error templates
- Provide alternative APIs that encompass passing state and handling actions to/from the route, loading, and error templates

- Out of scope:
- Deprecating and eliminating controllers -- but the goal of this RFC is to provide a _path_ to remove controllers from Ember altogether.
Expand All @@ -42,24 +35,6 @@ This'll explore how controllers are used and how viable alternatives can be for

## Detailed design

First, what would motivate someone to use a Controller today? Borrowing from [this blog post](https://medium.com/ember-ish/what-are-controllers-used-for-in-ember-js-cba712bf3b3e) by [Jen Weber](https://twitter.com/jwwweber):

1. You need to use query parameters in the URL that the user sees (such as filters that you use for display or that you need to send with back end requests)

2. There are actions or variables that you want to share with child components

3. (2a) You have a computed property that depends on the results of the model hook, such as filtering a list

All of this behavior can be implemented elsewhere, and most of what controllers _can_ do is already more naturally covered by components.

### 1. Query Params

See this RFC for [adding query params to the router service](https://github.com/emberjs/rfcs/pull/380), query-param management would be pulled out of the controller entirely.

### 2. Passing State and Handling Actions to/from the Template

In order to fully eliminate the controller, there _must_ be a way to handle computed properties or state along with responding to actions from the template. Components can cover this already, and would be an intuitive way to interact with the view and behavioral layer.

Currently, controllers + templates must be used in the app by having:
- `app/controllers/{my-route-name/or-path}.js`
- `app/templates/{my-route-name/or-path}.hbs`
Expand Down Expand Up @@ -398,6 +373,8 @@ More specifically recommended will be to use a separate component for each of th

In the release that makes these capabilities a default, any pages mentioning the controller, or the route template, or the loading/error templates should be removed or updated to fit the new way of using components

`ember g route` should generate a route with the proposed format in this RFC and an associated component.


## Drawbacks

Expand Down