Sha256: 0225ca2257df616edb0be15dae5364d8751d5cee0c3540c383bc79e8880cd53b

Contents?: true

Size: 412 Bytes

Versions: 6

Compression:

Stored size: 412 Bytes

Contents

-- Let's us cancel a callback

wax.callback = function(callback)
  local object = {callback = callback}

  function object.cancel(self)
    self.canceled = true
  end
  
  function object.__call(self, ...)
    if self.canceled then 
      return 
    end
    
    local args = self.scope and {self.scope, ...} or {...}
    self.callback(unpack(args))
  end

  setmetatable(object, object)
  
  return object
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
candle-0.0.7 lib/candle/generators/lua/wax/lib/stdlib/helpers/callback.lua
candle-0.0.6 lib/candle/generators/lua/wax/lib/stdlib/helpers/callback.lua
candle-0.0.4 lib/candle/generators/lua/wax/lib/stdlib/helpers/callback.lua
candle-0.0.3 lib/candle/generators/lua/wax/lib/stdlib/helpers/callback.lua
candle-0.0.2 lib/candle/generators/lua/wax/lib/stdlib/helpers/callback.lua
candle-0.0.1 lib/candle/generators/lua/wax/lib/stdlib/helpers/callback.lua