vrld / hump

LÖVE Helper Utilities for Massive Progression
http://hump.readthedocs.org
1.08k stars 153 forks source link

[hump.signal] stopping signal propagation #97

Open pcornier opened 6 years ago

pcornier commented 6 years ago

Would be great to have a way to stop the signal propagation:

function Registry:emit(s, ...)
  for f in pairs(self[s]) do
    if f(...) == false then return end
  end
end

so we could stop the signal using:

Signal.register('mousepressed', function(x, y)
  ...
  return false
end)
vrld commented 6 years ago

Since pairs can iterate in any order, this would be non-deterministic. Would that be acceptable?

pcornier commented 6 years ago

That's true, maybe not a good idea. Anyway, I patched emit on my project and it does the job for now. Do you think of another way to stop the signal without patching the lib?