I am new to a lot of the CanJS functionality (so far only used model and constructs) and realized it would be beneficial to use something like the CanJS equivalent of Backbone (which I am also quite new to).
So, I have one question concerning the use of components:
How should I handle the situation where one component should trigger an event in another component?
Use case:
I am creating a simple note taking app. One component has a list of notes and their operations (select, delete, add new) and another the editor.
By selecting a note the editor component should load it from the back-end (or local storage).
Normally I would use one of the following approaches:
- Call a method on the editor component telling it to re-render using a specific note-id.
- Use a pub/sub implementation: The editor would subscribe to a "new-note-selected" event in the note-list component.
What would be the best way to do this in CanJS?
---- update ----
I did a little more reading of the documentation. With can.route I can do the following using can.control:
"{can.route} change": function(...)
But I didn't see any support for this with components, or am I wrong?.