Update the wiki with inplace callbacks
aka-momo opened this issue · 2 comments
aka-momo commented
Elevator pitch, describe and sell us your feature request
As a developer,
I want be able to have documentation about in place Callbacks
so that I could use the functionality
Is your feature request related to a problem
Have you considered any alternatives
Additional Comments
I'm not able to update the wiki since it is open only for collabrators, Here is an example of what we can add to the inplace callbacks
section:
We can do worker before
or after
perform which will be invoked on a specific interactor in an organizer by passing a block or passing a method name to the .organize method:
class MyInteractor1 < ActiveInteractor::Base
def perform
puts 'MyInteractor1'
end
end
class MyInteractor2 < ActiveInteractor::Base
def perform
puts 'MyInteractor2'
end
end
class MyOrganizer < ActiveInteractor::Organizer::Base
organized do
add MyInteractor1
add MyInteractor2, before: -> { puts "Before" }, after: :print_after
end
private
def print_after
puts "After"
end
end
MyOrganizer.perform
"MyInteractor1"
"Before"
"MyInteractor2"
"After"
#=> <MyOrganizer::Context...>
aaronmallen commented
aka-momo commented
Thank you 🙏