3 ms·
My homegrown front-end library has a similar pub-sub mechanism (probably a bit more heavyweight than the OP's implementation) and uses it extensively for UI cou
by HillRat 12y ago
My homegrown front-end library has a similar pub-sub mechanism (probably a bit more heavyweight than the OP's implementation) and uses it extensively for UI coupling, data-binding and asynchronous call management. It's certainly a lot more ceremony than passing functions around, but it also makes it possible to determine who's generating and dispatching on events, simplifies debugging, and allows you to drop in functionality by simply wiring an object up to listen for the appropriate messages (particularly nice for logging). It's overkill for probably 80% of the pages you write, but really nice to have in the toolbox for the more complex problems.