From 420e42aacccbac2d81fedc5ff861442a4ce70c1d Mon Sep 17 00:00:00 2001 From: mike-thompson-day8 Date: Mon, 2 Nov 2015 22:37:46 +1100 Subject: [PATCH] Introduce a router loop, not based on core-async --- src/re_frame/router.cljs | 234 ++++++++++++++++++++++++++++----------- 1 file changed, 168 insertions(+), 66 deletions(-) diff --git a/src/re_frame/router.cljs b/src/re_frame/router.cljs index 0ebb35d..1d6f654 100644 --- a/src/re_frame/router.cljs +++ b/src/re_frame/router.cljs @@ -1,81 +1,184 @@ (ns re-frame.router (:refer-clojure :exclude [flush]) - (:require-macros [cljs.core.async.macros :refer [go-loop go]]) - (:require [reagent.core :refer [flush]] - [re-frame.handlers :refer [handle]] - [re-frame.utils :refer [warn error]] - [cljs.core.async :refer [chan put! EventQueue :quiescent #queue [])) -;; -- dispatch ------------------------------------------------------------------------------------ +;; --------------------------------------------------------------------------- +;; Dispatching +;; (defn dispatch "Send an event to be processed by the registered handler. @@ -85,9 +188,9 @@ " [event-v] (if (nil? event-v) - (error "re-frame: \"dispatch\" is ignoring a nil event.") ;; nil would close the channel - (put! event-chan event-v)) - nil) ;; Ensure nil return. See https://github.com/Day8/re-frame/wiki/Beware-Returning-False + (error "re-frame: \"dispatch\" is ignoring a nil event.") ;; nil would close the channel + (enqueue event-queue event-v)) + nil) ;; Ensure nil return. See https://github.com/Day8/re-frame/wiki/Beware-Returning-False (defn dispatch-sync @@ -98,6 +201,5 @@ (dispatch-sync [:delete-item 42])" [event-v] (handle event-v) - nil) ;; Ensure nil return. See https://github.com/Day8/re-frame/wiki/Beware-Returning-False - + nil) ;; Ensure nil return. See https://github.com/Day8/re-frame/wiki/Beware-Returning-False