Fork me on GitHub
#re-frame
<
2022-09-12
>
erwinrooijakkers14:09:31

I added day8.re-frame-10x as described in the docs for shadow-cljs (https://github.com/day8/re-frame-10x#easy-setup) but when starting the application I get this error:

File: jar:file:/Users/$USER/.m2/repository/org/babashka/sci/0.2.8/sci-0.2.8.jar!/sci/impl/namespaces.cljc
failed to require macro-ns "sci.impl.namespaces", it was required by "sci.impl.namespaces"
Error in phase :compile-syntax-check
RuntimeException: No such var: edamame/normalize-opts
do I need to add something else?

👀 1
p-himik14:09:57

The error complains about babashka/sci/edamame - there's nothing about re-frame-10x in there. Are you absolutely sure it was just the dependency on re-frame-10x that triggered that error?

erwinrooijakkers14:09:07

Adding

[borkdude/edamame "1.0.0"]
fixes it.

erwinrooijakkers14:09:43

This is the diff, without adding the borkdude/edamame I get the above error

erwinrooijakkers14:09:44

maybe I need to put [day8.re-frame/tracing "0.6.2"] also in project.clj

erwinrooijakkers14:09:07

nope, by adding [day8.re-frame/tracing "0.6.2"] instead of [borkdude/edamame "1.0.0"] I get the same error

erwinrooijakkers14:09:42

Maybe something else is configured wrongly, but don’t know, this works for now 🙂

p-himik14:09:11

But what depends on sci in the first place?

erwinrooijakkers14:09:55

I don’t see sci or edamame referenced in day8.re-frame/re-frame10x nor day8.re-frame/tracing

p-himik14:09:26

Ah, re-frame-10x depends on zprint which depends on sci. But in my case, sci explicitly depends on edamame, so not sure why it isn't the case for you, apparently.

p-himik14:09:29

Surely lein has some dependency tree tool that tells you which dependencies are included or excluded, and why - I'd try searching for examame there and see if something excludes it. Before you add it to your dependencies, of course.

erwinrooijakkers21:09:13

Ah of course, did not think about that, I’ll check

erwinrooijakkers21:09:22

thanks for digging already

erwinrooijakkers21:09:33

this is one

[metosin/malli "0.2.1"]
   [borkdude/dynaload "0.2.2"]
   [borkdude/edamame "0.0.11-alpha.15"]
   [org.clojure/test.check "1.1.0"]

erwinrooijakkers21:09:33

Maybe Malli includes an earlier version that had no normalize-opts

erwinrooijakkers21:09:12

in it for a long time

isak17:09:44

Is it safe to deref subscriptions in reagent/create-class/:get-initial-state ? I'm thinking yes it should be, right?

p-himik17:09:26

If it doesn't give you a warning about a non-reactive context, then should be safe.

isak18:09:08

Oh right I need to update. Thanks!

👍 1
Wilson Velez23:09:40

I have a very internal component that doesn’t know to much about other components, but the other components need to know when something happens inside the first one. is there a way to have multiple implementations (effects) to respond the just one event? or what strategy do you suggest to do that?

;;in the internal component
(reg-event-fx
 :my-effect
 (fn [{:keys [db]} [_]]
   {:db (do-something-with-db)
    :new-event db}))

;; first implementation in other component
(reg-fx
 :new-event 
 (fn [db]
  (do-something1)) 

;; second implementation in a third component
(reg-fx
 :new-event 
 (fn [db]
  (do-something2)) 

p-himik23:09:54

There is a way, but you're much better off by making that component explicitly pluggable in some sort. Basically, an observer pattern.

Wilson Velez23:09:05

thanks @U2FRKM4TW you are always so helpful.

Wilson Velez23:09:55

now I need to study about the observer pattern 🧑‍🎓

p-himik23:09:50

The easiest way here is to have a vector of functions in your app-db that that event handler needs to call. But not be the best way though - depends on the use case.

Wilson Velez23:09:01

so I need some mechanism to register the functions that I need to call from the other components to the app-db, now when the :new-event is raised it could extract the functions from the db and call them…something like that?

p-himik23:09:34

Yep. Or it might be not in app-db but in some other place. But it might things more complex than needed - up to you.

Wilson Velez23:09:34

I was also thinking in a callback fn as param as last resource

p-himik23:09:57

If the observers are not changing in run time, that's a good solution. Often, it helps making such low level components not depend on re-frame at all and just pass all the values and functions directly from parent components.

Wilson Velez23:09:42

yes, that’s a good reason. thanks again @U2FRKM4TW I think I have all need to solve my issue now.

👍 1