Make router work with 0.6.0 of reagent (and be backwards compatible)

This commit is contained in:
Mike Thompson 2015-12-22 00:17:33 +11:00
parent ddec78442d
commit 00f706688a
1 changed files with 5 additions and 2 deletions

View File

@ -1,5 +1,6 @@
(ns re-frame.router (ns re-frame.router
(:require [reagent.impl.batching :refer [do-later]] (:require [reagent.impl.batching]
[reagent.core]
[re-frame.handlers :refer [handle]] [re-frame.handlers :refer [handle]]
[re-frame.utils :refer [error]] [re-frame.utils :refer [error]]
[goog.async.nextTick])) [goog.async.nextTick]))
@ -59,7 +60,9 @@
;; A map from event metadata keys to the corresponding "run later" functions ;; A map from event metadata keys to the corresponding "run later" functions
(def later-fns (def later-fns
{:flush-dom do-later ;; after next annimation frame {:flush-dom (if (exists? reagent.core/after-render) ;; after next annimation frame
(.-after-render reagent.core) ;; reagent >= 0.6.0
(.-do-later reagent.impl.batching)) ;; reagent < 0.6.0
:yield goog.async.nextTick}) ;; almost immediately :yield goog.async.nextTick}) ;; almost immediately
(defprotocol IEventQueue (defprotocol IEventQueue