Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expressing Action Prerequisite or "after" #97

Closed
adomokos opened this issue Dec 21, 2016 · 2 comments
Closed

Expressing Action Prerequisite or "after" #97

adomokos opened this issue Dec 21, 2016 · 2 comments

Comments

@adomokos
Copy link
Owner

Usually, the order of actions are dependent on previous actions, but I caught myself rearranging orders where it makes sense. However, sometimes the action has to be invoked after another one.

Would it make sense to introduce an after macro that would express this dependency?

So the action would look like this:

class SomeAction
  extend LightService::Action

  after SomeOtherAction
  expects :user
  promises :client

  executed do |ctx|
    ...
  end
end

And when somebody places this action into a workflow where the SomeOtherAction was not invoked prior to SomeAction#execute call, it will throw an error.

I am hesitant to add this logic as it could be abused, but maybe, somebody else bumped into this before.

Let me know what you think!

@Jared-Prime
Copy link

The formalization of this pattern starts to make my brain hurt ( cf. ordered monoids ). My confusion revolves around the question: once a programmer imposes an ordering on a single action, should she make explicit that ordering on all the actions under that organizer? I would say "yes"; the trouble, then, would be that the action where ordering is expressed as suggested would then require an ordering in any organizer that includes that action. The way to resolve that would simply be to express the ordering under the organizer, and leave the action agnostic to its caller.

In short, it would seem to me that an action should have no knowledge of its fellow actions; an action should only have knowledge about its context.

I would like to see more examples where the proposed change is useful, tho

@adomokos
Copy link
Owner Author

adomokos commented Jan 3, 2017

This would add more restriction to an action with limiting the options for reuse. It was an idea, thanks for taking the time and thinking about it @Jared-Prime. I am closing it.

@adomokos adomokos closed this as completed Jan 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants