Comments (4)
What is the error message?
from hump.
Can you please give more information? What did you expect and what did you get instead? Your example ...
signal.register("slot", function()
print("Foo")
signal.register("slot", function() print("Bar") end)
print("Baz")
end)
signal.emit("slot")
... Works as expected:
Foo
Baz
Bar
The timer example also works as expected:
timer.after(1, function()
print("Foo")
timer.after(1, function()
print("Bar")
end)
end)
timer.update(1) --> Foo
timer.update(1) --> Bar
from hump.
signal = require("signal")
function register()
signal.register(1, function()
print("Foo")
signal.register(1, function() print("Bar") end)
print("Baz")
end)
end
for i=1, 10 do
register()
signal.emit(1)
signal.clear(1)
print("---")
end
(LuaJIT 2.0.5)
luajit.exe test.lua
Foo
Baz -- <<--- I think this is right. Because Bar is register after emit.
---
Foo
Baz
---
Foo
Baz
---
Foo
Baz
---
Foo
Baz
Bar
---
Foo
Baz
Bar
---
Foo
Baz
---
Foo
Baz
---
Foo
Baz
Bar
---
Foo
Baz
Bar
---
(lua 5.1.4)
lua5.1.exe test.lua
Foo
Baz
Bar
---
Foo
Baz
Bar
---
Foo
Baz
Bar
---
Foo
Baz
Bar
---
Foo
Baz
Bar
---
Foo
Baz
Bar
---
Foo
Baz
Bar
---
Foo
Baz
Bar
---
Foo
Baz
Bar
---
Foo
Baz
Bar
---
(I'm sorry, My English is not good)
from hump.
more sample
signal = require("signal")
function test1(mode)
print("Foo")
signal.register(1, function() print("Bar") end)
print("Baz")
end
function register()
signal.register(1, test1)
signal.register(1, function() end)
signal.register(1, function() end)
signal.register(1, function() end)
end
for i=1,10 do
register()
signal.emit(1)
signal.clear(1)
print("---")
end
luajit.exe test.lua
Foo
Baz
Bar
Foo --<< call twice
Baz
---
Foo
Baz
Foo
Baz
---
Foo
Baz
Bar
---
Foo
Baz
Foo
Baz
---
Foo
Baz
Foo
Baz
---
Foo
Baz
Bar
Foo
Baz
---
Foo
Baz
Bar
Foo
Baz
---
Foo
Baz
Foo
Baz
---
Foo
Baz
Foo
Baz
---
Foo
Baz
Bar
Foo
Baz
---
lua5.1.exe test.lua
Foo
Baz
Bar
---
Foo --<<
Baz
---
Foo --<<
Baz
---
Foo
Baz
Bar
---
Foo --<<
Baz
---
Foo
Baz
Bar
---
Foo
Baz
---
Foo
Baz
Bar
---
Foo
Baz
Bar
---
Foo --<<
Baz
---
Timer
timer = require("timer")
function register()
timer.after(0.5, function()
print("Foo")
-- Bar total 1 second
timer.after(0.5, function() print("Bar") end)
print("Baz")
end)
timer.after(0.5, function() end)
timer.after(0.5, function() end)
timer.after(0.5, function() end)
end
for i=1,10 do
register()
timer.update(0.5)
timer.clear()
print("---")
end
luajit.exe test3.lua
Foo
Baz
Bar -- Bar 1 sec but call 0.5 sec
---
Foo
Baz
Bar
---
Foo
Baz
---
Foo
Baz
---
Foo
Baz
Bar
---
Foo
Baz
Bar
---
Foo
Baz
Bar
---
Foo
Baz
Bar
---
Foo
Baz
Bar
---
Foo
Baz
Bar
---
lua5.1.exe test3.lua
Foo
Baz
---
Foo
Baz
---
Foo
Baz
Bar
---
Foo
Baz
Bar
---
Foo
Baz
Bar
---
Foo
Baz
Bar
---
Foo
Baz
Bar
---
Foo
Baz
Bar
---
Foo
Baz
Bar
---
Foo
Baz
Bar
---
from hump.
Related Issues (20)
- Documentation typo HOT 1
- Documentation typo in "gamestate" HOT 1
- Timer: After caching timers "to_update", timer:cancel() doesn't apply until next timer:update() HOT 1
- Vector unexpected symbol HOT 1
- [hump.gamestate] textinput callback doesn't work properly HOT 3
- Camera documentation missing explanation about some parameters - worldCoords
- LOVE 11.0 requires extra arguments to setCanvas() at times
- Some minor things outlined in a forum post HOT 1
- hump.signal - crashes when sending "clear", "remove" or any other signals that share a name with a Registry function name. HOT 1
- Is there any maintainer for this repo? HOT 9
- Do I have to manually clear used timers? HOT 1
- [hump.timer] Subject values are not precise to targets after timer has completed HOT 6
- docs: camera:attach doesn't have any of its arguments listed in the docs
- Arguments to atan2 are reversed HOT 1
- [hump.timer] freeze timer HOT 1
- attempt to perform arithmatic on self.x and self.y doesnt work
- attempt to index local 'layer' (a nil value) HOT 1
- Add a vector:angleBetween() function HOT 4
- [hump.signal] stopping signal propagation HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hump.