Method: Inferno::Event#once

Defined in:
lib/inferno.rb

#once(event, context, &callback) ⇒ Object

Just like on, but causes the bound callback to only fire once before being removed. Handy for saying “the next time that X happens, do this”.

Parameters:

  • [event (String)

    name]

  • [on (Object)

    what object run callback]

  • [callback] (Proc)


25
26
27
28
# File 'lib/inferno.rb', line 25

def once(event, context, &callback)
  on(event, context, &callback)
  on(event, self) { off(event) }
end