Skip to content

Commit

Permalink
Break out timer into it's own namespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmeiklejohn committed Nov 24, 2012
1 parent 659e042 commit bfe0e3a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/cljs/shafty/timer.cljs
@@ -0,0 +1,21 @@
;; Copyright (c) Christopher Meiklejohn. All rights reserved.
;;
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 which can be found in the file
;; LICENSE.html at the root of this distribution. By using this
;; software in any fashion, you are agreeing to be bound by the terms of
;; this license. You must not remove this notice, or any other, from
;; this software.
;;
(ns shafty.timer
(:use [shafty.event :only [event]]))

(defn timer!
"Generate a new timer at a given interval, and bind to a new event
stream."
([interval]
(timer! interval js/Date))
([interval value-fn]
(let [e (event)]
(js/setInterval (fn []
(-notify-watches e nil (value-fn))) interval) e)))

0 comments on commit bfe0e3a

Please sign in to comment.