This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-11
Channels
- # aleph (38)
- # announcements (6)
- # aws (1)
- # beginners (47)
- # calva (21)
- # cider (47)
- # cljs-dev (18)
- # clojure (40)
- # clojure-europe (7)
- # clojure-india (2)
- # clojure-italy (9)
- # clojure-nl (11)
- # clojure-norway (2)
- # clojure-sanfrancisco (1)
- # clojure-spec (17)
- # clojure-sweden (2)
- # clojure-uk (73)
- # clojurescript (10)
- # cursive (6)
- # datascript (12)
- # datavis (2)
- # defnpodcast (1)
- # duct (5)
- # emacs (36)
- # figwheel (2)
- # figwheel-main (10)
- # juxt (12)
- # leiningen (1)
- # midje (1)
- # nrepl (9)
- # off-topic (25)
- # pedestal (3)
- # portkey (3)
- # quil (2)
- # re-frame (45)
- # reagent (1)
- # ring (3)
- # ring-swagger (36)
- # rum (1)
- # shadow-cljs (48)
- # spacemacs (1)
- # speculative (50)
- # testing (2)
- # tools-deps (27)
- # yada (4)
martian lets you have global and route-specific interceptors, and has re-frame bindings https://github.com/oliyh/martian/tree/master/re-frame @hoopes
is the handler in rf/reg-event-fx
only called if it's actually doing a change? Or maybe it's the panel from re-frame-10x
that doesn't show events that doesn't actually change the state
@victorbjelkholm429 No, it'll always be called. Should show up in 10x as well, just tried it with an event that just returns nil
.
@oliy do you know of any way to have more than one instance of martian within re-frame? the code looks like it holds the martian object under ::martian :m
(i've seen this pattern elsewhere too - i was hoping to have more than one API that i'm talking to)
i used to have a similar pattern going in re-graph but re-graph now supports multiple named instances
Has anybody else been having issues with calling a subscription from the Clojure repl (see below) -- Clojurescript --
cljs.user=> (require '[slm.components.typeahead.subscriptions :as subscriptions])
nil
cljs.user=> (require '[re-frame.core :as re-frame])
nil
cljs.user=> (re-frame/subscribe [::subscriptions/typeahead])
#<Reaction 42: {:query "a", :suggestions {:loading? true}}>
cljs.user=>
`
-- Clojure --
user=> (require '[slm.components.typeahead.subscriptions :as subscriptions])
nil
user=> (require '[re-frame.core :as re-frame])
nil
user=> (re-frame/subscribe [::subscriptions/typeahead])
user=> Execution error (ArityException) at re-frame.subs/reg-sub$subs-handler-fn (subs.cljc:325).
Wrong number of args (1) passed to: slm.components.typeahead.subscriptions/eval47498/fn--47499
Hi @jacobhaag17! I would bet you that your subscription function doesn't take 2 arguments
because cljs, like js is permissive of calling functions with the wrong number of arguments (naughty js), but clojure (like java) doesn't allow that
so perhaps somewhere reframe is calling
(your-subscription-function-that-takes-one-arg db [::subscriptions/typeahead])
which works fine in JS but not Java.@U051GFP2V So with the jvm it's trying to send an additional paramater?
Ah I see, so now we know the cause, do we know how to resolve this issue for the jvm? @U051GFP2V
Here is what the subscriptions look like
(re-frame/reg-sub
::suggestions
(fn [db [_ query]]
(get-in db [:typeahead :suggestions])))
(re-frame/reg-sub
::query
(fn [db [_ query]]
(get-in db [:typeahead :query])))
(re-frame/reg-sub
::typeahead
(fn []
[(re-frame/subscribe [::query])
(re-frame/subscribe [::suggestions])])
(fn [[query suggestions]]
{:query query
:suggestions suggestions}))
Calling (re-frame/subscribe [::query])
works fine
It does, but for some reason now I get the error "Wrong number of args (2) passed to: slm.components.typeahead.subscriptions/eval29377/fn--29381"
when I change the subscription too
(re-frame/reg-sub
::typeahead
(fn []
[(re-frame/subscribe [::query])
(re-frame/subscribe [::suggestions])])
(fn [[query suggestions] _]
{:query query
:suggestions suggestions}))
this page shows the (fn [] ..
after ::typeahead also takes two arguments: https://github.com/Day8/re-frame/blob/master/docs/SubscriptionFlow.md#example-reg-sub-raw
ah, thanks @U06D9RGQM
@U06D9RGQM would you have any recommendations for how to call the subscription?
Calling the subscription like this should work like it is right now: (re-frame/subscribe [::subscriptions/typeahead])
but change
(re-frame/reg-sub
::typeahead
(fn []
[(re-frame/subscribe [::query])
(re-frame/subscribe [::suggestions])])
(fn [[query suggestions] _]
{:query query
:suggestions suggestions}))
to
(re-frame/reg-sub
::typeahead
(fn [_query-v-ignored _second-arg-ignored]
[(re-frame/subscribe [::query])
(re-frame/subscribe [::suggestions])])
(fn [[query suggestions] _]
{:query query
:suggestions suggestions}))
Unfortunately already tried that and still get the same error Wrong number of args (1) passed to: slm.components.typeahead.subscriptions/eval27593/fn--27594
@U06D9RGQM
@mateus.pimentel.w I know there is a popular tool called re-frame-10x
which gives you advanced logging and inspection of events
but i wanted to see they printed on console too to see in which event a particular javascript error ocurred
@mateus.pimentel.w you could make something like the debug intercepter but that would just print the event vector
but you would have to put the intercepter into any of the events where you cared about the logging
basically just delete the after key here: https://github.com/Day8/re-frame/blob/master/src/re_frame/std_interceptors.cljc#L47
I think i will do some low level stuff and inject code into some of the re-frame functions at run time
@mateus.pimentel.w the debug
interceptor does exactly what you want I think
And it can be easily left out of production builds