This code will throw errors due to the registered sub handler throwing an exception. The exception gets cached so that the same error appears after fixing and re-registering the sub at the repl.
In order to repeat remove the assert or register a new sub which doesn't throw then re-render the app.
The workaround is calling clear-subscription-cache!.
Ideas to improve this behaviour and make it less surprising
- clear the cache when subs are re-registered to avoid data getting out of sync
- don't cache exceptions
(ns hello-world.case1
(:require [re-frame.core :as rf]
[reagent.dom :as rdom]))
(rf/reg-sub ::throwing-sub (fn [_ _] (assert (= 2 4)) "fn sub"))
(defn app []
[:p @(rf/subscribe [::throwing-sub])])
(rdom/render [app] (js/document.getElementById "app"))
This code will throw errors due to the registered sub handler throwing an exception. The exception gets cached so that the same error appears after fixing and re-registering the sub at the repl.
In order to repeat remove the assert or register a new sub which doesn't throw then re-render the app.
The workaround is calling
clear-subscription-cache!.Ideas to improve this behaviour and make it less surprising