In a single paged application, would this be the best way to bind and trigger events? A websocket connects to the server and initializes, then it calls the page load function etc.
var app = {};
websocket.init(function()
{
//websocket is loaded, call page load function
$(app).trigger('load');
});
function logout()
{
websocket.logout(function()
{
//now logged out
$(app).trigger('loggedout');
}
}
//page.js
$(app).bind('load', function()
{
});
$(app).bind('loggedout', function()
{
});
1 Answer