@piratdavid wrote:
Here's the structure of a component that I'm presenting in a News feed plugin on a page that's not tied to the forum part of Discourse. My question is: Am I doing it right?
A controller that creates the components model and stores it as a variable on itself.
A model that fetches its own data with ajax on creation and start a subscription on the messagebus that is passed on from the constructor.
A component that receives its model from the creation in markup. It cancels the subscription on willDestroyElement and reinitiates it on didInsertElement.
A template representing the markup.I'm not sure if this is the right way to go. Is it right to pass the model this way? Should a component have a model? Should the model fetch it's own data? It is not as self contained as I would have thought a component should be. Should it even be implemented as a component?
Hope to get some clarity in this.
Thanks
David
Posts: 2
Participants: 2