Skip to content

Commit

Permalink
Repro for reframe issue: Improve exception handing associated with subs
Browse files Browse the repository at this point in the history
  • Loading branch information
olivergeorge committed Jul 10, 2020
1 parent 0a7ab27 commit 5034ad8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
3 changes: 2 additions & 1 deletion deps.edn
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
{:deps {org.clojure/clojurescript {:mvn/version "1.10.758"}}}
{:deps {org.clojure/clojurescript {:mvn/version "1.10.758"}
re-frame {:mvn/version "0.12.0"}}}
23 changes: 21 additions & 2 deletions src/hello_world/core.cljs
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
(ns hello-world.core)
(ns hello-world.core
(:require [reagent.core :as r]
[reagent.dom :as rdom]
[re-frame.core :as rf]))

(println "Hello world!")
(rf/reg-sub
::throwing-sub
(fn [_ _]
(assert (odd? 2))
"fn sub"))

(defn app []
[:p @(rf/subscribe [::throwing-sub])])

(defn error-boundary []
(let [*error (r/atom nil)]
(r/create-class
{:get-derived-state-from-error (fn [e] (reset! *error e))
:component-did-catch (fn [_ _ _] true)
:reagent-render (fn [form] (if @*error [:div (str @*error)] form))})))

(rdom/render [error-boundary [app]] (js/document.getElementById "app"))

0 comments on commit 5034ad8

Please sign in to comment.