This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-04-30
Channels
- # announcements (7)
- # beginners (103)
- # boot (62)
- # cider (14)
- # clara (10)
- # cljdoc (4)
- # cljs-dev (2)
- # cljsrn (2)
- # clojure (51)
- # clojure-dev (15)
- # clojure-europe (13)
- # clojure-italy (25)
- # clojure-japan (3)
- # clojure-nl (4)
- # clojure-spec (6)
- # clojure-uk (9)
- # clojurescript (72)
- # clojureverse-ops (2)
- # community-development (2)
- # core-async (35)
- # cursive (16)
- # datascript (1)
- # datomic (12)
- # duct (2)
- # emacs (2)
- # fulcro (9)
- # graphql (5)
- # hoplon (5)
- # leiningen (3)
- # luminus (1)
- # nyc (1)
- # off-topic (41)
- # other-languages (1)
- # pathom (16)
- # pedestal (2)
- # re-frame (44)
- # reitit (1)
- # shadow-cljs (33)
- # spacemacs (12)
- # test-check (9)
- # tools-deps (15)
- # vim (4)
What is the best way to handle creating mutiple similar components? Let’s say for example my app-db is
{:gods {:a {:name "A"
:nature "T"}
:b {:name "B"
:nature "F"}
:c {:name "C"
:nature "random"}}}
Is it recommended to create subscriptions for :god-a-nature, :god-b-nature, :god-c-nature separately? (seems dirty…) Would it be the same for names as well? Now if I want to create list of these 3 gods my initial thought was that I would pass(?) god-a to reagent component (form-2) and set up subscriptions for the specific god. But actually it doesn’t work that way because subscriptions are defined separately and I would have to subscribe to specific subscriptions I’ve set up for each god and each property. What is the recommended way to write this? Sorry, I’m a noob at clojure and re-frame, just trying to learn.I can't seem to be able to use with-redefs
on an interceptor. Is there any other way I can mock out this interceptor? I'm using day8.re-frame/test
@jeeq I didn't test if any of that works. But hopefully it gives you an idea of how to deal with that data structure.
@caleb.macdonaldblack how are you using with-redefs?
with-redefs
has no effect here. The real interceptor is being called instead
Yeah I know that with-redefs
doesn't work for things like promises. Not sure how I could go about testing this using rf-test though
I could break the function out and test that.
Although if I could mock that interceptor I feel that would be best
it’s been awhile since I did a lot of things with interceptors, but I think you could put your own interceptor in the chain that could replace the sync-user-persisted
one
the interceptor chain is kept in the context I think, so you can have an intercepter that on :begin
loops through the interceptors and replaces the one with :id :sync-user-persisted
with your :fake-interceptor
I'd like to test the event handler function and that the interceptor is being called
Interestingly enough this with-redefs
is working
rf-test/run-test-sync
makes rf/dispatch
synchronous for testing purposes
So with-redefs
should and does work. Now that I know I can redef interceptors I just need to figure out what is preventing my other one from working
https://github.com/Day8/re-frame-test/blob/master/src/day8/re_frame/test.cljc#L270 run-test-sync
actually essentially redefs dispatch
to dispatch-sync
with-redefs
doesn't have any effect with this arrangement
But it does here
So perhaps interceptors are async
I think what’s happening is that reg-event-fx
stores the interceptor foobar
as a value the first way
I'm an idiot
I'm defining that before I use with-redefs
And it's referring to the value
adding an indirection of (foobar)
helps because it does a lookup of what’s in the foobar
var at when the event is run
maybe even using a var-quote:
(rf/reg-event-fx
:foobar
[#'foobar]
(fn [_ _ ]))
would fix itI tried that it doesn't work
Breaking out the interceptor function and redefining that works
Nope. Must have var-quoting
Alright that is working for me now. Thanks for your help @lilactown 🙂
anyone get NPE errors with re-frame-10x here:
(defn log-trace? [trace]
(let [render-operation? (or (= (:op-type trace) :render)
(= (:op-type trace) :componentWillUnmount))
component-path (get-in trace [:tags :component-path] "")]
(if-not render-operation?
true
(not (str/includes? component-path "devtools outer")))))
the component-path seems to be null