forked from rust-lang/rfcs
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request rust-lang#421 from emberjs/deprecate-application-c…
…ontroller-props Deprecate Application Controller Router Properties
- Loading branch information
Showing
1 changed file
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
- Start Date: 2018-19-12 | ||
- RFC PR: https://github.com/emberjs/rfcs/pull/421 | ||
- Ember Issue: (leave this empty) | ||
|
||
# Deprecate Application Controller Router Properties | ||
|
||
## Summary | ||
|
||
This RFC proposes the deprecation of `ApplicationController#currentPath` and `ApplicationController#currentRouteName`. | ||
|
||
## Motivation | ||
|
||
These APIs are no longer needed as the `RouterService` now has `RouterService#currentPath` and `RouterService#currentRouteName`. | ||
These fields are only ever present on the application controller which is a weird special casing that we would like to remove. | ||
Additionally, it's likely that there are very few if any consumers of this API as it is not documented. | ||
|
||
## Transition Path | ||
|
||
If you are reliant on `ApplicationController#currentPath` and `ApplicationController#currentRouteName` you can get the same functionality from the `RouterService` to migrate, inject the `RouterService` and read the `currentRouteName` or `currentPath` off of it. | ||
|
||
Before: | ||
|
||
```js | ||
// app/controllers/application.js | ||
import Controller from '@ember/controller'; | ||
import fetch from 'fetch'; | ||
|
||
export default Controller.extend({ | ||
store: service('store'), | ||
|
||
actions: { | ||
sendPayload() { | ||
fetch('/endpoint', { | ||
method: 'POST', | ||
body: JSON.stringify({ | ||
route: this.currentRouteName | ||
}) | ||
}); | ||
} | ||
} | ||
}) | ||
``` | ||
|
||
After: | ||
|
||
```js | ||
// app/controllers/application.js | ||
import Controller from '@ember/controller'; | ||
import fetch from 'fetch'; | ||
|
||
export default Controller.extend({ | ||
store: service('store'), | ||
router: service('router'), | ||
|
||
actions: { | ||
sendPayload() { | ||
fetch('/endpoint', { | ||
method: 'POST', | ||
body: JSON.stringify({ | ||
route: this.router.currentRouteName | ||
}) | ||
}); | ||
} | ||
} | ||
}) | ||
``` | ||
|
||
## How We Teach This | ||
|
||
There is likely very few consumers of this functionality and migration path is covered by existing documentation. | ||
|
||
## Drawbacks | ||
|
||
This may introduce churn that we are not aware of. | ||
|
||
## Alternatives | ||
|
||
No real alternative other than keep setting the properties. | ||
|
||
## Unresolved questions | ||
|
||
Optional, but suggested for first drafts. What parts of the design are still | ||
TBD? |