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

pipeline-style functions in a step #30

Open
ElChache opened this issue Feb 28, 2019 · 2 comments
Open

pipeline-style functions in a step #30

ElChache opened this issue Feb 28, 2019 · 2 comments

Comments

@ElChache
Copy link
Collaborator

It seems a very common case in our code base with fonda to have steps that just take the input of the previous step and don' use anything on the context:

[{:processor (fn [...] (xhr-request ...))
  :path [:xhr-response]}
 {:processor (fn [ctx] (validate-previous-xhr-response (:xhr-response ctx))
  :path [xhr-response]}
{:processor (fn [ctx] (do-something-with-xhr-response (:xhr-response ctx)))
 :path [:result-path]}]

It would be great to have a way to have some functions getting the output of the previous one

@ElChache
Copy link
Collaborator Author

ElChache commented Feb 28, 2019

If we use keywords to represent functions, it could be done like this:

;; returns an xhr request promise
(defn xhr-request [ctx] ...) 

 ;; Returns the response data if no error on the response
(defn validate-xhr-request [xhr-response] ...)

[{:processor [::xhr-request ::validate-xhr-response]
  :path [:xhr-response]}
 {:processor (fn [ctx] (do-something-with-xhr-response (:xhr-response ctx) (:other-thing-in-ctx ctx))
  :path [:result-path]}

@ElChache
Copy link
Collaborator Author

I also think the pipelined-functions could also be represented as maps with {:name and :fn} instead of keywords but of course this is debatable

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

1 participant