collectiveidea / interactor

Interactor provides a common interface for performing complex user interactions.
MIT License
3.36k stars 212 forks source link

On success callback for Organizers? #195

Closed bradherman closed 3 years ago

bradherman commented 3 years ago

We currently have rollback callbacks for when the stack fails, but it would be nice to also be able to have success callbacks:

organize CreatePurchase, AuthorizeCard

If card authorization fails:

def rollback
  context.purchase.fail!
end

If it succeeds

def success
  context.purchase.success!
end

It could be accomplished by adding a MarkSuccess interactor at the end, but I like the idea of defining callback chains.

arthurhess commented 3 years ago

On a side note, @bradherman, one can also use after hooks (which don't run in case the context is failed).

bradherman commented 3 years ago

Oh good call @arthurhess ... Not quite as explicit, but adding a helper method to my BaseInteractor would be super easy :+1: