You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I feel like it's clearer to separate inputs/outputs:
inputs are passed in the initializer
outflow is the output
Each waterfall is independent and has its own outflow.
You can get data from another service by grabbing data from its outflow with your desired local name.
Nothing is global or shared per default.
Using or not block params to retrieve outflow is really a matter of context. Lets see this with examples.
If you work with a class, you dont need outflow as block param:
class Services::Registration::AddUser
include Waterfall
def initialize(user_params, event_id)
@user_params = user_params
@event_id = event_id
end
def call
with_transaction do
chain(user: :user) do
Services::CreateUser.new(@user_params)
end
chain do
# here you can access outflow directly as its builtin within the object
Services::Registration::Subscribe.new(outflow.user, @event_id)
end
end
end
end
But whenever you trigger the flow you need block params. In a controller for instance:
Wf.new
.chain(user: :user) do
Services::Registration::AddUser(user_params, event_id)
end
.chain do |outflow| # here you need the outflow from the block
render json: { user_id: outflow.user.id }
end
.on_dam do |error_pool|
render json: { errors: error_pool }, status: 422
end
I'm a bit confused by the ambiguity of passing arguments to
call
on a Waterfall as opposed to attaching them to the outflow contextGenerally the arguments being passed are coming from an outflow anyway, I don't know when to use one over the other
Additionally, it seems each object has its own
@outflow
property, so passing the outflow as a block is not always needed?The text was updated successfully, but these errors were encountered: