mirror of
https://github.com/rayaman/multi.git
synced 2026-09-05 07:27:35 -04:00
Connections can be % with functions
This commit is contained in:
+8
-37
@@ -1,42 +1,13 @@
|
||||
package.path = "../?/init.lua;../?.lua;"..package.path
|
||||
multi, thread = require("multi"):init{print=true,findopt=true}
|
||||
|
||||
local conn1, conn2 = multi:newConnection(), multi:newConnection():fastMode()
|
||||
conn3 = conn1 + conn2
|
||||
|
||||
conn1(function()
|
||||
print("Hi 1")
|
||||
local conn1 = multi:newConnection()
|
||||
local conn2 = function(a,b,c) return a*2, b*2, c*2 end % conn1
|
||||
conn2(function(a,b,c)
|
||||
print("Conn2",a,b,c)
|
||||
end)
|
||||
|
||||
conn2(function()
|
||||
print("Hi 2")
|
||||
conn1(function(a,b,c)
|
||||
print("Conn1",a,b,c)
|
||||
end)
|
||||
|
||||
conn3(function()
|
||||
print("Hi 3")
|
||||
end)
|
||||
|
||||
function test(a,b,c)
|
||||
print("I run before all and control if things go!")
|
||||
return a>b
|
||||
end
|
||||
|
||||
conn4 = test .. conn1
|
||||
|
||||
conn5 = conn2 .. function() print("I run after it all!") end
|
||||
|
||||
conn4:Fire(3,2,3)
|
||||
|
||||
conn5(function()
|
||||
print("Test 1")
|
||||
end)
|
||||
|
||||
conn5(function()
|
||||
print("Test 2")
|
||||
end)
|
||||
|
||||
conn5(function()
|
||||
print("Test 3")
|
||||
end)
|
||||
|
||||
conn5:Fire()
|
||||
conn1:Fire(1,2,3)
|
||||
conn2:Fire(1,2,3)
|
||||
Reference in New Issue
Block a user