transflow
transflow copied to clipboard
Step order is of when using with: option
require 'bundler'
Bundler.require
container = {
increment: -> i { i + 1 },
square: -> i { i * i }
}
class Responder
def self.increment_success(input)
puts 'increment'
end
def self.square_success(input)
puts 'square'
end
def self.add_one_success(input)
puts 'add_one'
end
end
t1 = Transflow(container: container){
step(:increment, publish: true){
step(:square, publish: true)
}
}
t2 = Transflow(container: container){
step(:add_one, with: :increment, publish: true){
step(:square, publish: true)
}
}
t3 = Transflow(container: container){
step(:add_one, with: :increment, publish: true)
step(:square, publish: true)
}
t4 = Transflow(container: container){
step(:square, publish: true)
step(:add_one, with: :increment, publish: true)
}
t5 = Transflow(container: container){
step(:square, publish: true)
step(:increment, publish: true)
t1.subscribe(Responder)
t2.subscribe(Responder)
t3.subscribe(Responder)
t4.subscribe(Responder)
t5.subscribe(Responder)
puts t1[1]
puts t2[1]
puts t3[1]
puts t4[1]
puts t5[1]
increment
square
4
add_one
square
3
square
add_one
2
add_one
square
4
increment
square
4