How should we update the interactor code which existed in hanami v1, upgrading hanami from v1 to v2?

I use hanami/interactor now with hanami v1, but I found hanami/interactor was removed from hanami v2.

Does Anyone know why hanami/interactor was removed?
And how we should change the old interactor? (For example we think we’ll change expose to attr_reader and error! method to raise. Is it the right way in hanami v2? ref: Module: Hanami::Interactor — Hanami API docs | v1.3.3)

Hanami 2 is a complete rewrite atop the dry-rb family of gems, so a lot of things were deleted and replaced with those tools.

I’m not super familiar with Hanami::Interactor, but it looks like dry-monads’ Do Notation is probably intended to be the replacement.

1 Like

There’s no official replacement and we’re still thinking what to do with this. Having a “blessed” solution like this is tricky because it’s not really possible to come up with something generic enough for most people to be happy with. I started experimenting with a library similar to dry-transaction lately and maybe something will come out of it.

In general, you can use whatever you prefer, plenty of existing options are out there. If you’re happy with the interactors you could port them to work with Hanami 2.0, it does not make any assumptions about this type of libraries so really, no limits here.

1 Like

Thank you for your comment!

I first know dry-monads.
Certainly, it seems similar to the use of Interactor.

I’ll read more about this!

Thank you for your detail guidance.

I understood your situation.

Because we keep the code simple and not too dependent on framework, we’ll use simple class , like pure ruby object (We don’t use expose method but attr_reader, and don’t use error! method but raise) as Interactor.