NativeEvent:unbind

From Wake
Jump to: navigation, search

Unbind a function from an event. The function (and table, if specified) must be the same exact instance as was bound initially, or else this function will do nothing. Having the same exact implementation in a function is not enough for unbind to work.

Function

Synopsis

NativeEvent:unbind(func)
NativeEvent:unbind(t, func)

Arguments

function func

The function to unbind from the event.


table t

The table initially specified to NativeEvent:bind.

Returns

None.


Example

The following will print i each tick, until i reaches 100.

local i = 1
local function onTick()
  print(i)
  i = i + 1
  if i >= 100 then
    engine.tick:unbind(onTick)
  end
end

engine.tick:bind(onTick)

See Also