Skip to content

Instantly share code, notes, and snippets.

@retro
Last active February 18, 2017 15:23
Show Gist options
  • Save retro/fa0df937c9abcbf0ebbecf4a5844c8c0 to your computer and use it in GitHub Desktop.
Save retro/fa0df937c9abcbf0ebbecf4a5844c8c0 to your computer and use it in GitHub Desktop.
;; Pipelines are a new way to write controller action handlers for Keechma.
;; They are a part of the (soon-to-be-released) Keechma Toolbox - https://github.com/keechma/keechma-toolbox
;;
;; In this case we implemented a live Movie Search (it's hitting http://www.omdbapi.com/) where the pipeline is called on every
;; keypress, and makes request after a 500ms timeout. This pipeline is exclusive so if a pipeline is running when the next
;; keypress happens, it will be cancelled (along with the AJAX request) and another pipeline will be started.
;;
;; https://github.com/keechma/keechma-toolbox/tree/master/src/cljs/keechma/toolbox/pipeline
(def search-controller
(pp-controller/constructor
(fn [] true)
{:search (pp/exclusive
(pipeline! [value app-db]
(when-not (empty? value)
(pipeline! [value app-db]
(delay-pipeline 500)
(movie-search value)
(println "SEARCH RESULTS:" value)))))}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment