Skip to content
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