My Authors
Read all threads
@Wellington_Tds @garrickcheung One of the biggest problems with the route-action helper is that it becomes very difficult to track the flow of data in your application. Data Down Actions Up exists to be a predictable flow of data through every level of your application. route-action allows you to bypass it.
@Wellington_Tds @garrickcheung The reason this is bad is that you now have to reason about where an action is going. Let's say you have three levels of nested routes in your application and 10 levels of nested components. You put a route-action on the leaf component (level 10). Where does that go? Which route?
@Wellington_Tds @garrickcheung As applications grow and scale, this problem becomes worse. What if you've broken your application into multiple addons or engines? route-action might be targeting an action that isn't even defined in the SAME REPOSITORY.
@Wellington_Tds @garrickcheung Also, how do you test this? Routes don't exist in integration tests, so if you have a component putting a route-action on child component, you literally can't test that it works without a full-on acceptance test. This also means that component can't be used in other routes.
@Wellington_Tds @garrickcheung Now, you might read all of this and say "Well, we can be disciplined. We'll tell people to never use route-action in component templates, only route templates." Then why do you need this at all? If you're only using it in route templates, that feature already exists in Ember.
@Wellington_Tds @garrickcheung That feature is called CONTROLLERS. Controllers exist to bind data and actions to the route template. That's literally the purpose they serve. How do you think you can access "model" in a route template? Because it exists on the controller, passed in via setupController
@Wellington_Tds @garrickcheung If you think you're not using Controllers now, you're wrong. Every single route has a controller. If you didn't make a file for it, it still exists, Ember is just creating a default Controller for you. So if you need something beyond the default behavior, why are you afraid?
@Wellington_Tds @garrickcheung Ultimately, if you need to hold custom state outside the model or bind actions in the route template, that is what controllers exist for. Yes, at some indefinite point in the future, controllers might be removed from Ember. That hasn't happened yet, and there is no specific plan.
@Wellington_Tds @garrickcheung When/if controllers are removed from Ember, there will be a stable upgrade path. It will likely even be codemoddable. Until then, use controllers when you need them. If you want to make it a best practice to keep controllers light on state and mostly use them for actions, great.
@Wellington_Tds @garrickcheung But ultimately, please don't go out of your way to avoid using controllers at all costs. There's no reason for it, and using controllers is still a best practice for Ember development. Don't create pain for yourself when you don't have to.
Missing some Tweet in this thread? You can try to force a refresh.

Enjoying this thread?

Keep Current with AxleHellfire

Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

Twitter may remove this content at anytime, convert it as a PDF, save and print for later use!

Try unrolling a thread yourself!

how to unroll video

1) Follow Thread Reader App on Twitter so you can easily mention us!

2) Go to a Twitter thread (series of Tweets by the same owner) and mention us with a keyword "unroll" @threadreaderapp unroll

You can practice here first or read more on our help page!

Follow Us on Twitter!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3.00/month or $30.00/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!