simplify names: pause, resume, regularize run-queue
- pause-run -> pause - begin-resume -> resume - no longer a multi-step process - begin-run -> run-queue - so all action function names match their keywords
This commit is contained in:
parent
38120c4913
commit
bde07088a4
|
@ -73,9 +73,9 @@
|
||||||
(-process-1st-event [this])
|
(-process-1st-event [this])
|
||||||
(-run-next-tick [this])
|
(-run-next-tick [this])
|
||||||
(-run-queue [this])
|
(-run-queue [this])
|
||||||
(-pause-run [this later-fn])
|
|
||||||
(-exception [this ex])
|
(-exception [this ex])
|
||||||
(-begin-resume [this]))
|
(-pause [this later-fn])
|
||||||
|
(-resume [this]))
|
||||||
|
|
||||||
|
|
||||||
;; Want to understand this? Look at FSM in -fsm-trigger?
|
;; Want to understand this? Look at FSM in -fsm-trigger?
|
||||||
|
@ -101,12 +101,12 @@
|
||||||
|
|
||||||
(-run-next-tick
|
(-run-next-tick
|
||||||
[this]
|
[this]
|
||||||
(goog.async.nextTick #(-fsm-trigger this :begin-run nil)))
|
|
||||||
|
|
||||||
(-exception
|
(-exception
|
||||||
[_ ex]
|
[_ ex]
|
||||||
(set! queue #queue []) ;; purge the queue
|
(set! queue #queue []) ;; purge the queue
|
||||||
(throw ex))
|
(throw ex))
|
||||||
|
(goog.async.nextTick #(-fsm-trigger this :run-queue nil)))
|
||||||
|
|
||||||
;; Process all the events currently in the queue, but not any new ones.
|
;; Process all the events currently in the queue, but not any new ones.
|
||||||
;; Be aware that events might have metadata which will pause processing.
|
;; Be aware that events might have metadata which will pause processing.
|
||||||
|
@ -116,15 +116,15 @@
|
||||||
(if (zero? n)
|
(if (zero? n)
|
||||||
(-fsm-trigger this :finish-run nil)
|
(-fsm-trigger this :finish-run nil)
|
||||||
(if-let [later-fn (some later-fns (-> queue peek meta keys))]
|
(if-let [later-fn (some later-fns (-> queue peek meta keys))]
|
||||||
(-fsm-trigger this :pause-run later-fn)
|
(-fsm-trigger this :pause later-fn)
|
||||||
(do (-process-1st-event this)
|
(do (-process-1st-event this)
|
||||||
(recur (dec n)))))))
|
(recur (dec n)))))))
|
||||||
|
|
||||||
(-pause-run
|
(-pause
|
||||||
[this later-fn]
|
[this later-fn]
|
||||||
(later-fn #(-fsm-trigger this :begin-resume nil)))
|
(later-fn #(-fsm-trigger this :resume nil)))
|
||||||
|
|
||||||
(-begin-resume
|
(-resume
|
||||||
[this]
|
[this]
|
||||||
(-process-1st-event this) ;; do the event which paused processing
|
(-process-1st-event this) ;; do the event which paused processing
|
||||||
(-fsm-trigger this :finish-resume nil)) ;; do the rest of the queued events
|
(-fsm-trigger this :finish-resume nil)) ;; do the rest of the queued events
|
||||||
|
@ -145,11 +145,11 @@
|
||||||
|
|
||||||
;; processing has already been scheduled to run in the future
|
;; processing has already been scheduled to run in the future
|
||||||
[:scheduled :add-event] [:scheduled #(-add-event this arg)]
|
[:scheduled :add-event] [:scheduled #(-add-event this arg)]
|
||||||
[:scheduled :begin-run] [:running #(-run-queue this)]
|
[:scheduled :run-queue] [:running #(-run-queue this)]
|
||||||
|
|
||||||
;; processing one event after another
|
;; processing one event after another
|
||||||
[:running :add-event ] [:running #(-add-event this arg)]
|
[:running :add-event ] [:running #(-add-event this arg)]
|
||||||
[:running :pause-run ] [:paused #(-pause-run this arg)]
|
[:running :pause ] [:paused #(-pause this arg)]
|
||||||
[:running :exception ] [:quiescent #(-exception this arg)]
|
[:running :exception ] [:quiescent #(-exception this arg)]
|
||||||
[:running :finish-run] (if (empty? queue) ;; FSM guard
|
[:running :finish-run] (if (empty? queue) ;; FSM guard
|
||||||
[:quiescent]
|
[:quiescent]
|
||||||
|
@ -157,12 +157,12 @@
|
||||||
|
|
||||||
;; event processing is paused - probably by :flush-dom metadata
|
;; event processing is paused - probably by :flush-dom metadata
|
||||||
[:paused :add-event ] [:paused #(-add-event this arg)]
|
[:paused :add-event ] [:paused #(-add-event this arg)]
|
||||||
[:paused :begin-resume] [:resuming #(-begin-resume this)]
|
|
||||||
|
|
||||||
;; processing the event that caused the queue to be paused
|
;; processing the event that caused the queue to be paused
|
||||||
[:resuming :add-event ] [:resuming #(-add-event this arg)]
|
[:resuming :add-event ] [:resuming #(-add-event this arg)]
|
||||||
[:resuming :exception ] [:quiescent #(-exception this arg)]
|
[:resuming :exception ] [:quiescent #(-exception this arg)]
|
||||||
[:resuming :finish-resume] [:running #(-run-queue this)]
|
[:resuming :finish-resume] [:running #(-run-queue this)]
|
||||||
|
[:paused :resume ] [:running #(-resume this)]
|
||||||
|
|
||||||
(throw (str "re-frame: state transition not found. " fsm-state " " trigger)))]
|
(throw (str "re-frame: state transition not found. " fsm-state " " trigger)))]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue