Plug icon indicating copy to clipboard operation
Plug copied to clipboard

Sequences of actions

Open bearinld004 opened this issue 6 years ago • 1 comments

Hi @s4cha I like this concept of actions you have going on here. Just wondering about chaining them together into a sequence isolating the view from the actions, so the view only touches the sequences of actions.

I similar concept implemented in https://cerebraljs.com/ I used that in the JS realm and really liked their declarative style. I wonder if this is something that can be done with Plug.

Cheers!

bearinld004 avatar Nov 14 '19 18:11 bearinld004

Hi @bearinld004 Thanks for the kind words. The actions in plug were created to abstract and encapsulate an input/output, in order to easily use dependency inversion principle on a per action basis rather than entire service objects. A concrete example (that we use in our app) is to be able to replace actions on the fly, for testing purposes.

In app:

FetchArticles.self <~ GoFetchArticles()

In tests:

FetchArticles.self <~ MockFailingFetchArticles()

Here, this enables us to replace a single call in unit tests to make a unit test deterministic and synchronous, taking the networking part out of the equation.

I'm not sure how similar this is with cerebralJS but feel free to play around with the concept :) Chaining should be possible ex: Action <A, B> + Action <B, C> = Action<A,C>

s4cha avatar Dec 13 '19 09:12 s4cha