define [ 'underscore', 'backbone', 'globals', 'cs!models/user' ], (_, Backbone, globals, UserModel) -> # TODO: this class should actually store UserModel's, for now it is only trigerring events UsersCollection = Backbone.Collection.extend model: UserModel initialize: -> # TODO: not the best solution, but can't do it on initialize because globals.connection doesn't # exist yet start: -> globals.connection.bind "connection:connected", @_registerEvents, @ _registerEvents: -> globals.events.on "connection:user_list_change", (users) => globals.events.trigger("users:user_list_change", users) globals.events.on "connection:load_users", (users) => globals.events.trigger("users:load_users", users) globals.events.on "connection:user_join", (userid, username) => globals.events.trigger("users:user_join", userid, username) globals.events.on "connection:user_leave", (userid) => globals.events.trigger("users:user_leave", userid) globals.events.on "connection:setPresenter", (userid) => globals.events.trigger("users:setPresenter", userid) UsersCollection