mirror of
https://github.com/penpot/penpot.git
synced 2025-02-13 10:38:13 -05:00
Add better impl for util timers.
This commit is contained in:
parent
3bb991da0b
commit
653e0b5669
1 changed files with 13 additions and 2 deletions
|
@ -4,8 +4,19 @@
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) 2016-2017 Andrey Antukh <niwi@niwi.nz>
|
;; Copyright (c) 2016-2017 Andrey Antukh <niwi@niwi.nz>
|
||||||
|
|
||||||
(ns uxbox.util.timers)
|
(ns uxbox.util.timers
|
||||||
|
(:require [beicon.core :as rx]))
|
||||||
|
|
||||||
(defn schedule
|
(defn schedule
|
||||||
[ms func]
|
[ms func]
|
||||||
(js/setTimeout func ms))
|
(let [sem (js/setTimeout #(func) ms)]
|
||||||
|
(reify rx/ICancellable
|
||||||
|
(-cancel [_]
|
||||||
|
(js/clearTimeout sem)))))
|
||||||
|
|
||||||
|
(defn interval
|
||||||
|
[ms func]
|
||||||
|
(let [sem (js/setInterval #(func) ms)]
|
||||||
|
(reify rx/ICancellable
|
||||||
|
(-cancel [_]
|
||||||
|
(js/clearInterval sem)))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue