Hi all, I’ve been working on my first addon for a couple of months, and am looking for some feedback. It basically enables your routes to render components directly, skipping the controller / non-component template layer.
It’s based loosely on the Routable Components RFC, and while the RFC has been closed, the goals remain the same so this addon seeks to achieve those.
In addition, the addon has very minimal monkey-patching of Ember internals, which means you can drop the addon into an existing app and use both classic routing as well as the addon simultaneously.
I’m curious whether you tried an implementation that automatically provides an (invisible to users) controller implementation for every route. It seems like you could achieve the API you want with less customization that way.
For example, it would mean people could use regular {{outlet}} instead of learning about {{component-outlet}}.
Thanks for taking a look! If I understand you correctly, this would entail monkey patching Ember internals to modify {{outlet}}?
At the moment the “routable components” aspect of the addon is achieved almost entirely using public API (hacking of Ember internals is minimal – only for query params support). I think there have been other addons that attempted to implement your RFC through monkey patching, but I wanted to approach it without changing how Ember currently works.
I think there is some win in being able to install the addon without affecting all existing routes, as well as in making the addon more future-proof. Though I do see your point about the learning curve being slightly steeper since there is less automatic magic going on.
No, I’m suggesting that you may be able to automatically fill in a default Controller that renders the desired component with the desired model. This gives users an API that needs no controllers or top-level route templates because you’ve already filled them in behind the scenes.
For example, if your addon provided app/templates/-component-shim.hbs like:
And their my-component will render and will receive the model.
That’s just a sketch, there would be lots of other things you could add to make the API you want. I think the one thing that would probably require hackery is splatting out a dynamic set of attributes onto the component.