This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-01-24
Channels
- # arachne (3)
- # beginners (39)
- # boot (3)
- # cider (91)
- # cljs-dev (56)
- # cljsrn (4)
- # clojure (267)
- # clojure-dusseldorf (1)
- # clojure-estonia (1)
- # clojure-greece (2)
- # clojure-italy (6)
- # clojure-nl (2)
- # clojure-russia (18)
- # clojure-spec (27)
- # clojure-uk (136)
- # clojurescript (19)
- # core-async (2)
- # cursive (6)
- # datomic (17)
- # emacs (2)
- # fulcro (86)
- # graphql (4)
- # hoplon (13)
- # jobs-discuss (7)
- # jobs-rus (1)
- # keechma (34)
- # keyboards (7)
- # leiningen (5)
- # luminus (4)
- # lumo (8)
- # off-topic (13)
- # om (6)
- # onyx (26)
- # re-frame (22)
- # reagent (1)
- # reitit (2)
- # remote-jobs (8)
- # ring (3)
- # ring-swagger (5)
- # rum (8)
- # shadow-cljs (45)
- # specter (6)
- # unrepl (16)
- # yada (15)
@mihaelkonjevic In the edb docs, get-item-by-id
et al need a reference to the schema and the store. How do you hand these over in the context of a component?
Say I have a dropdown select, and I want an on-change handler for the selection to look up something in edb by key and display it
I use subscriptions for that. They know about the scheme and the store
You can have subscriptions that accept args, or you can read some other data from the app-db
If you need to select something based on the form value, you can access the form state in the app-db.
I can give you an example in ~30 mins when I’m back in the office
I don’t want to make it a form because it’s a one off selection. The subscription taking args sounds like what I need.
“They know about the scheme and the store” the subscription gets the app-db-atom as its argument, right? And I can just refer the edb-schema inside the subscriptions ns?
defentitydb
macro exports the dbal functions from here https://github.com/keechma/entitydb/blob/master/src/entitydb/core.cljs#L503 with schema partially applied as a first argument
so if you call defentitydb
inside a namespace all of these functions will be defined
and you can use them as for instance edb/insert-item
yeah, but I don’t know if there’s another way except like here https://github.com/keechma/example-place-my-order/blob/master/client/src/client/edb.cljs
which is verbose
yes, these generated by macro work like that, macro does something like the file I just pasted
Is it possible (not asking you to do it) to add like ^:args and ^:docstring metadata to macro generated fns?
I guess it is, macro is here https://github.com/keechma/keechma-toolbox/blob/master/src/clj/keechma/toolbox/edb.clj . It’s incredibly ugly since this is one of the first macros I wrote 🙂
yeah macros are beyond my understanding right now, but will keep it in mind--if I ever contribute to keechma it should be in-library documentation (rather than blogposts)
Yeah, I’m planning to reorganize everything
I’ll pull the content from blog posts to examples / docs
and probably create a gitbook for that
anyhoo, here’s an example subscription that’s having extra arguments:
and then you can use it from the component (keechma.toolbox.ui/sub> ctx :some-subscription cart)
Thanks, this makes sense. I ended up putting it int he controller for the component--referring edb namespace in a controller is an OK pattern, right?
I guess it would have to be, because it’s just the equivalent of using get-in
or assoc-in
on :kv, just for :edb
yeah, it’s a good pattern. I usually have a lot of controllers like that, any user action that is not a form is implemented with controllers https://github.com/gothinkster/clojurescript-keechma-realworld-example-app/blob/master/src/cljs/realworld/controllers/user_actions.cljs#L35