OK so in reading one more time through the documentation, the best thing to make it completely event driven is to listen in on when the message center variable I set (i.e - "channels") gets updated, and when it does to update the view.
Anybody got any good examples on how to make that happen?
This really should be its own topic. Please create a new topic next time.
This contains a small code snippet that shows how a view can register a listener on the view that will listen for a message center broadcast. It's basically just a method bound to the view that takes a callback as its only parameter. This callback (_dispatcher in the example) inspects the payload key, making sure it's the same key that was used to store the information. Then, you can update a grid, as in that example.
Any time data is stored or removed in the message center an event is broadcast that any subscribers will receive. For example:
CODE
KONtx.messages.store("vids", json.videos);
Any function or method can subscribe to the
message center:
CODE
myFunction.subscribeTo(KONtx.messages, KONtx.messages.eventType, myFunction);
or
(function (event) {
if (event.payload.key === "vids") {
//this is the expected payload, so do something;
}
}).subscribeTo(KONtx.messages, KONtx.messages.eventType, this);
Note that while knowing when something is stored in the message center is cool, you can just use it for storage and then fetch it later when needed:
CODE
//pseudo-code;
onApplicationStartup: function () {
KONtx.messages.store("vids", json.videos);
};
//in a view;
updateView: function () {
var myVids = KONtx.messages.fetch("vids");
};
Hope that helps.