Skip to content

Instantly share code, notes, and snippets.

@daveray
Created February 13, 2013 01:07
Show Gist options
  • Save daveray/4784716 to your computer and use it in GitHub Desktop.
Save daveray/4784716 to your computer and use it in GitHub Desktop.
(defn ^Observable drop-while
[f ^Observable xs]
(Observable/create (fn [^Observable subject]
(let [dropping (atom true)
subscription (subscribe* xs
(fn [v]
(when (or (not @dropping)
(not (reset! dropping (boolean (f v)))))
(emit subject v)))
(fn [e] (error subject e))
(fn [] (done subject)))]
(Observable/createSubscription #(unsubscribe subscription))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment