From daa15a6978b1eb5250de00c18196ebf21859f2fe Mon Sep 17 00:00:00 2001 From: Chad Hietala Date: Wed, 19 Dec 2018 14:49:27 -0500 Subject: [PATCH 1/3] Deprecate Application Controller Router Properties --- ...-deprecate-application-controller-props.md | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 text/0000-deprecate-application-controller-props.md diff --git a/text/0000-deprecate-application-controller-props.md b/text/0000-deprecate-application-controller-props.md new file mode 100644 index 00000000000..5e97087172f --- /dev/null +++ b/text/0000-deprecate-application-controller-props.md @@ -0,0 +1,78 @@ +- Start Date: 2018-19-12 +- RFC PR: (leave this empty) +- Ember Issue: (leave this empty) + +# 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: 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? From c89de58b8b67fe01a9f9f953ef42bd79cfc5f845 Mon Sep 17 00:00:00 2001 From: Ricardo Mendes Date: Wed, 19 Dec 2018 20:51:12 +0000 Subject: [PATCH 2/3] Update and rename 0000-deprecate-application-controller-props.md to 0421-deprecate-application-controller-props.md --- ...deprecate-application-controller-props.md} | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) rename text/{0000-deprecate-application-controller-props.md => 0421-deprecate-application-controller-props.md} (83%) diff --git a/text/0000-deprecate-application-controller-props.md b/text/0421-deprecate-application-controller-props.md similarity index 83% rename from text/0000-deprecate-application-controller-props.md rename to text/0421-deprecate-application-controller-props.md index 5e97087172f..5c6233fd4a2 100644 --- a/text/0000-deprecate-application-controller-props.md +++ b/text/0421-deprecate-application-controller-props.md @@ -1,17 +1,20 @@ - Start Date: 2018-19-12 -- RFC PR: (leave this empty) +- RFC PR: https://github.com/emberjs/rfcs/pull/421 - Ember Issue: (leave this empty) -# Summary +# Deprecate Application Controller Router Properties -This RFC proposes the deprecation of `ApplicationController#currentPath` and `ApplicationController#currentRouteName`. +## Summary +This RFC proposes the deprecation of `ApplicationController#currentPath` and `ApplicationController#currentRouteName`. -# Motivation +## 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. +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 +## 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. @@ -24,6 +27,7 @@ import fetch from 'fetch'; export default Controller.extend({ store: service('store'), + actions: { sendPayload() { fetch('/endpoint', { @@ -47,6 +51,7 @@ import fetch from 'fetch'; export default Controller.extend({ store: service('store'), router: service('router'), + actions: { sendPayload() { fetch('/endpoint', { @@ -60,19 +65,19 @@ export default Controller.extend({ }) ``` -# How We Teach This +## How We Teach This There is likely very few consumers of this functionality and migration path is covered by existing documentation. -# Drawbacks +## Drawbacks This may introduce churn that we are not aware of. -# Alternatives +## Alternatives No real alternative other than keep setting the properties. -# Unresolved questions +## Unresolved questions Optional, but suggested for first drafts. What parts of the design are still TBD? From daadd1273283cd9235a3e4193f4a02b772151234 Mon Sep 17 00:00:00 2001 From: Ilya Radchenko Date: Fri, 21 Dec 2018 15:41:21 -0500 Subject: [PATCH 3/3] fix: typo --- text/0421-deprecate-application-controller-props.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/0421-deprecate-application-controller-props.md b/text/0421-deprecate-application-controller-props.md index 5c6233fd4a2..ecee23c151b 100644 --- a/text/0421-deprecate-application-controller-props.md +++ b/text/0421-deprecate-application-controller-props.md @@ -57,7 +57,7 @@ export default Controller.extend({ fetch('/endpoint', { method: 'POST', body: JSON.stringify({ - route: router.currentRouteName + route: this.router.currentRouteName }) }); }