This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-09-12
Channels
- # announcements (3)
- # babashka (6)
- # beginners (84)
- # biff (1)
- # cider (7)
- # cljsrn (1)
- # clojure (18)
- # clojure-australia (3)
- # clojure-dev (21)
- # clojure-france (1)
- # clojure-spec (6)
- # clojurescript (78)
- # datomic (34)
- # emacs (5)
- # exercism (32)
- # graalvm (1)
- # helix (2)
- # hyperfiddle (3)
- # lsp (36)
- # malli (4)
- # missionary (3)
- # off-topic (54)
- # re-frame (14)
- # releases (2)
- # sql (31)
- # vim (9)
Hi folks. Based on comment here a few days ago by @emccue I was inspired to try a pattern of wrappers around Re-frame subscriptions. I’ve written it up here: https://gist.github.com/jkrasnay/12ed298d1058d47ef6714618753a081f
I mean, I do appreciate the focus on having a symbol that will throw a compiler warning, not just anger a linter
but i'm still not sure about how best to tie "domain model function" to "registered subscription"
I didn’t think it was possible to have the linter detect typos in subscription keywords. That would certainly help avoid this wrapping stuff.
Can you elaborate on “domain model function”? I posted here because I’m unsure myself whether my wrapper is a good idea, so I’d appreciate hearing about your experience.
We did something similar (really for item 1) and it works ok, but an issue can be subscriptions that are more nested/complex. The symbol names get kind of goofy in such cases with --
separators for nesting, etc, to the point where it seems better to just use a vector with a keyword.
> Can you elaborate on “domain model function”? Well, i'm still hung up on how to take the "entire state of the world" and divide it into managable chunks
if you have a single structure - your "domain model" - you can make functions that work with that structure
subscriptions are magic lookup into the global scope and i don't know if the same things you write for a subscription would be good functions for working with a "nested" scope
After using this for a few days I’ve decided that the downsides outweigh the advantages, e.g. I can’t use LSP to find all references, which I can actually do with the plain subscription keyword. I can always pull out an accessor function in the few cases where some event could use the access pattern as the subscription.
Seems this is a common pattern for me. I start thinking “maybe a macro would help here” and I usually end up reverting it!
yeah - at least with what i described earlier with the defevent - the symbol we use the most is the one the linter can pick up