IoC とは
- 11. 反転した制御
eventMap map;
function listen(string event, function f)
{
map[event].push(f);
}
// implements (timer)
while(1) {
each( f in map[event] ) {
f();
}
sleep(1);
}
function playBeep()
{
beep();
}
listen( TimerEvent , playBeep );
function showCurrentTime()
{
t = getTime();
print( t.hour+ : +t.minutes+ : +t.seconds );
}
listen( TimerEvent , showCurrentTime );
frameworkimplements