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

Add an interval observer wrapper. #171

Open
wants to merge 1 commit into
base: 0.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion src/main/clojure/rx/lang/clojure/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
BlockingObservable
GroupedObservable]
[rx.subscriptions Subscriptions]
[rx.functions Action0 Action1 Func0 Func1 Func2]))
[rx.functions Action0 Action1 Func0 Func1 Func2]
[java.util.concurrent TimeUnit]))

(set! *warn-on-reflection* true)

Expand Down Expand Up @@ -289,6 +290,26 @@
(Observable/from ^Iterable s)
(empty)))

(defn ^Observable interval
"Make an observable from time intervals by specifying a time and unit of measurement.
The default unit of measurement is milliseconds.

See:
rx.Observable/interval
"
([ms] (interval ms :ms))
([amount unit]
(let [junit (condp #(%1 %2) unit
#{:ns :nanoseconds} TimeUnit/MILLISECONDS
#{:us :microseconds} TimeUnit/MILLISECONDS
#{:ms :milliseconds} TimeUnit/MILLISECONDS
#{:s :sec :seconds} TimeUnit/SECONDS
#{:min :minutes} TimeUnit/MINUTES
#{:hr :hours} TimeUnit/HOURS
#{:days} TimeUnit/DAYS
TimeUnit/MILLISECONDS)]
(Observable/interval amount junit))))

;################################################################################
; Operators

Expand Down