soma.js
Version:
soma.js is a javascript framework created to build scalable and maintainable applications.
25 lines (16 loc) • 527 B
text/coffeescript
((clock) ->
"use strict"
class clock.ClockMediator
constructor: (target, dispatcher, mediators, timer) ->
currentClock = null
dispatcher.addEventListener 'create', (event) ->
# destroy previous clock
if currentClock
timer.remove currentClock.update
currentClock.dispose()
# create clock
currentClock = mediators.create event.params, target
# register clock with timer model
timer.add currentClock.update
currentClock.update timer.time
) window.clock = window.clock or {}