Fork me on GitHub
#reitit
<
2018-08-31
>
Hannu Hartikainen11:08:44

Since I didn’t see a re-frame effect handler for reitit-frontend, I’ll share what I just wrote.

(ns my-app.fx.reitit
  (:require [reitit.frontend.easy :as rfe]
            [re-frame.core :refer [reg-fx]]))

(defn- reitit-fx [value]
  (if (keyword? value)
    (rfe/push-state value)
    (let [push    (:push-state value)
          replace (:replace-state value)
          params  (or push replace)
          f       (if push rfe/push-state rfe/replace-state)]
      (when params
        (apply f params)))))

(reg-fx :reitit reitit-fx)

👍 2