Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Break out timer into it's own namespace.
- Loading branch information
1 parent
659e042
commit bfe0e3a
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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))) |