@soundstep/soma
Version:
Soma is a javascript framework created to build scalable and maintainable applications.
30 lines (19 loc) • 573 B
JavaScript
(function(clock) {
'use strict';
var ClockMediator = function(target, emitter, mediators, timer) {
var currentClock;
emitter.addListener('create', function(params) {
// destroy previous clock
if (currentClock) {
timer.remove(currentClock.update);
currentClock.dispose();
}
// create clock
currentClock = mediators.create(target, params);
// register clock with timer model
timer.add(currentClock.update);
currentClock.update(timer.time);
});
};
clock.ClockMediator = ClockMediator;
})(window.clock = window.clock || {});