What’s a scalable way to handle actions triggered by a component that’s used across multiple routes?
Let’s say there’s a component called
tweet-block that’s displayed across multiple pages (in Twitter’s case, you can see it in your stream, or on a user’s profile page). This component has a
retweet action that causes the creation of a new tweet.
According to DDAU, this action should be send as a signal outside the component. But what is the best place to handle it?
- If you handle it in the current route, then you have to duplicate the action in all routes that use this component.
- Another option is to handle the action in a route that’s a common parent to all routes that use this component. But what if that parent happens to be the ApplicationRoute? What if there are 20 actions like this one? Do you just put all of them in the ApplicationRoute?
- You could implement this action in a mixin that’s added to each route that uses the component. Would this be an elegant way to do it?
- Or you could ignore DDAU and just use the store to create a new tweet inside the component.
Any thoughts? I’m curious if there’s going to be a good solution available once routable components land in Ember.