考虑以下 CoffeeScript 类:
class Event
trigger : (args...) =>
...
bind : (args...) =>
...
用例是:
message_received = new Event()
message_received.bind(alert)
message_received.trigger('Hello world!') # calls alert('Hello world')
有没有办法以调用具有“可调用对象”快捷Event
方式的方式编写类:.trigger(...)
message_received('Hello world') # ?
谢谢!