I’d appreciate if you could share you view/experience.
Suppose you have a view which contains several widgets that share some of the data (fetched from a server). For example we might have a tree, list and breadcrumbs widgets in the same view, naturally a name of a single item can be displayed in more than one widget at the same time. My question is what is the best practice of developing such views? Specifically:
- Are the widgets totally independent? (The easiest to implement, but suffer from performance problems)
- If the widgets are dependent, do they communicate through:
- A single model (introduces tight coupling between widgets and prevents further code evolution)
- Events (lose coupling but error-prone due to lose contract, less explicit code)
- Any other way
- Provided those widgets have their own controllers and scopes, how do you propagate the change notifications from the URL (or any other event) to all of them? For example if you wanna see an entity with a specific ID using URL routing, do you have a top-most view controller that is responsible to catch this change and notify all the widgets about it using some in-house mechanism, or do the widgets catch the event independently?
I guess all these questions are somehow related so feel free to answer them in whatever form/order you like.
Thanks.