Can someone explain to me the use of :: keywords, or point me to documentation about their use in re-frame?
I keep getting a warning that I don't have a subscription handler. In my subs namespace I have (reg-sub :server) and in views that is getting referenced as (subscribe ::sub/server). Is that correct?
See https://clojure.org/reference/reader#_literals -- "A keyword that begins with two colons is auto-resolved in the current namespace to a qualified keyword"
Or are you asking a different question? ::sub/server will resolve sub to its namespace alias, so you'll have :
(so :server is not a qualified keyword and therefore not the same as ::sub/server)
Ahhh I thought it was a re-frame specific thing.
If I change the subscription to just :server or the reg-sub to ::server the console spits out a ton of errors.
Somehow I've broken the template project 😆
::server means "resolve in the current ns" -- so it also produces a qualified keyword.
You need to be consistent and use ::sub/server everywhere and have the same require :as sub alias everywhere you need to use it.
Thanks
I got it going again. Needed to properly deref the subscription. Took me a minute to figure out where the error was in the stack trace.
One good reason to namespace your handler keys is to avoid collisions. There are a bunch of https://day8.github.io/re-frame/External-Resources/ providing handlers, and explicit ownership of names allows for seamless integration. Also, once you get used to it, namespacing adds a https://github.com/matthiasn/talk-transcripts/blob/master/Hickey_Rich/MaybeNot.md?plain=1#L425 https://github.com/matthiasn/talk-transcripts/blob/master/Hickey_Rich/MaybeNot.md?plain=1#L1026 https://github.com/matthiasn/talk-transcripts/blob/master/Hickey_Rich/MaybeNot.md?plain=1#L1202 to problem solving. Once you start being explicit about what things are, a lot of the code you thought you needed to validate, interpret and conform these things can just go away.
IMO the crucial DX arrived in clojure 1.11 with https://clojuredocs.org/clojure.core/require#example-653bbcc569fbcc0c226173f6. This lets you decouple ownership of names from code execution dependencies. That's how you can articulate re-frame's global virtual machine very conveniently & concisely.
Flow news:
• Removed :init, since we couldn't think of a strong enough use-case
• https://day8.github.io/re-frame/FAQs/UseASubscriptionInAnEventHandler/:
◦ Consolidated the other js/event faq page
◦ Wrote a more thorough problem description
◦ Added more solutions (like flows and polymorphic subs)
• Tweaked naming - flow<-, get-flow
• Lots of code refactoring & docs proofreading