re-frame

Nundrum 2023-11-21T19:27:08.796459Z

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?

seancorfield 2023-11-21T19:28:16.500139Z

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"

seancorfield 2023-11-21T19:29:05.484989Z

Or are you asking a different question? ::sub/server will resolve sub to its namespace alias, so you'll have :

seancorfield 2023-11-21T19:29:54.131319Z

(so :server is not a qualified keyword and therefore not the same as ::sub/server)

Nundrum 2023-11-21T19:33:02.908859Z

Ahhh I thought it was a re-frame specific thing.

Nundrum 2023-11-21T19:34:36.546739Z

If I change the subscription to just :server or the reg-sub to ::server the console spits out a ton of errors.

Nundrum 2023-11-21T19:37:16.987209Z

Somehow I've broken the template project 😆

seancorfield 2023-11-21T19:44:10.671719Z

::server means "resolve in the current ns" -- so it also produces a qualified keyword.

seancorfield 2023-11-21T19:44:38.241599Z

You need to be consistent and use ::sub/server everywhere and have the same require :as sub alias everywhere you need to use it.

👍 1
Nundrum 2023-11-21T19:52:49.798959Z

Thanks

Nundrum 2023-11-21T19:53:32.162409Z

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.

Kimo 2023-11-21T22:17:19.676039Z

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.

Kimo 2023-11-21T22:23:16.687709Z

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.

👍 1
Kimo 2023-11-21T03:02:16.450909Z

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

👀 2