Hi all,
I'd like some advice concerning how to achieve a context aware UI component.
Say we have some modules who all, in one or more of their views, want to give the user the ability to create a note containing one or more relevant tags, as well as viewing/editing notes relevant to the context. We could then have a Note module containing a create/edit/view note UI-component, a mediator and a proxy that takes care of storing and retrieving notes. Every module in need of this functionality could request the UI-component from the Note module (through pipes) and add it to the modules own view.
The question now is, what if the Note UI-component needs to be context aware when creating and showing notes. I.e. it should only show notes relevant to the context of the view it is currently residing in, in the module to which it has been exported. As the context of the view changes (i.e. a user selects a different row in a table) so should the Note UI-component.
How do we pass this context, from the module's view to the imported UI-component? and how do we continue to do so as the context changes.
Should the UI-component/Note-module, through it's Mediator and Commands somehow be aware of which module it has been exported to, and request the current context (through pipes) of this module before executing any actions, such as retrieving and storing notes? Or should the module utilizing the Note UI-component consequently (through pipes) notify the Note module of it's current context every time the context changes, so that this can be taken into consideration when retrieving and storing notes? Or something completely different perhaps :-)
Is there a best practices way of doing this?
Thanks in advance
Regards,
Simon