Fork me on GitHub

I want to remove a query param from the address bar every time a certain action is dispatched. Would you recommend using an :after interceptor, or writing an effect?


you can also take a look at the async reframe interceptor, it allows you to watch for certain events and dispatch new ones when certain conditions are met


hmm actually to link certain events with other events, why not just conditionally add :dispatch [:other-event args] in the event handler, like while using reg-event-fx?


I’d say that if it’s just one certain action it should be an effect. Interceptors are handy if you need same functionality around several different events.


Thanks! You could also kind of dispatch to the same effect from different event handlers, right?


Sorry for replying late! I’m poor at following these threads. But yeah, effects are reusable from event handlers. Re-Frame has stellar docs so I’ll just point you there for further info. 🙂


hello, i have put together a simple app, but it doesn't work

(defn clicker []
  (let [count (rf/subscribe [:count])]
     [:div (str "The count is: " @count)]
      {:on-click #(rf/dispatch [:increment-count])}
      "Increment count"]]))
i have the above component
 (fn [db _]
   (update db :count inc)))
the above event
 (fn [db _]
   (:count db)))
the above subscription... however, when i click the button in the component, i get an error
Uncaught TypeError: Illegal invocation
    at Object.schedule (batching.cljs:63)
    at Object.reagent$impl$batching$schedule [as schedule] (batching.cljs:113)
    at Object.reagent$ratom$rea_enqueue [as rea_enqueue] (ratom.cljs:102)
    at Object._handle_change (ratom.cljs:384)
    at reagent$ratom$handle_reaction_change (ratom.cljs:338)
    at Object.reagent$ratom$notify_w [as notify_w] (ratom.cljs:86)
    at Object.cljs$core$IReset$_reset_BANG_$arity$2 (ratom.cljs:140)
    at Object.cljs$core$_reset_BANG_ [as _reset_BANG_] (core.cljs:851)
    at Object.cljs$core$reset_BANG_ [as reset_BANG_] (core.cljs:4476)
    at fx.cljc:171
fwiw, it seems like the event fires correctly, but the subscription fails...not 100% sure 😞 full disclosure, i am using shadow-cljs and re-frame version 0.10.6 with reagent version 0.8.1 any help is greatly appreciated


@nolan.wright.other bump shadow-cljs or set :compiler-options {:fn-invoke-direct false} in the build config


I changed the default but reagent somehow didn't like that so I reverted it


you are probably on 2.8.32 which has the bad default


ah, yes i was using version 2.8.32


bumping fixed the issue


thanks thheller


thought i was going crazy