So I think what you want here is a Controller. A Controller can act as a middleman between your views and your entities (ie, Models & Collections).
Instead of calling the view directly, you call the controller, which fetches the entity and when done, instantiates the appropriate view.
Here's an example:
var MyView = Marionette.View.extend({
// ... view options
});
var MyCollection = Backbone.Collection.extend({
// ...
});
var MyController = Marionette.Controller.extend({
initialize: function(options) {
var self = this;
this.entity = options.entity;
this.region = options.region;
this.entity.fetch({
success: function() {
self.showBaseView();
}
});
},
getBaseView: function() {
return new MyView({ collection: this.entity });
},
showBaseView: function() {
this.region.show(this.getBaseView());
}
});
var controller = new MyController({
entity: new MyCollection(),
region: App.mainRegion
});
While this only uses one view and one region, you can have this configured however you need to depending on your app. The principle of it is that the Controller acts as an entry point that processes all the dependencies you need to render your multiple views/regions using one entity.
You can see a very simple example of this here: https://github.com/tnbKristi/kristi-yo/blob/master/app/scripts/modules/home/components/skills/skills-controller.js
only use parts of API call
? – IsabellaisabelleMessageCollection
and pass them into a new instance of that collection. – Isabellaisabelle