This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-11-04
Channels
- # beginners (56)
- # boot (11)
- # cider (1)
- # clojure (112)
- # clojure-denmark (4)
- # clojure-russia (7)
- # clojurescript (45)
- # component (1)
- # cursive (19)
- # data-science (10)
- # datacrypt (1)
- # datascript (22)
- # datomic (3)
- # defnpodcast (2)
- # emacs (4)
- # fulcro (26)
- # hoplon (21)
- # jobs-discuss (5)
- # klipse (5)
- # onyx (8)
- # portkey (1)
- # re-frame (8)
- # reagent (17)
- # ring (7)
- # shadow-cljs (14)
- # spacemacs (9)
- # vim (4)
I'll try to implement these live data funcs in my app
it's planned since the beginning and it kinda works in my head
@vinnyataide sounds interesting, but I have no idea what you mean š
@tony.kay live data functionality like meteor
@vinnyataide The method I was using was this: 1. Send a subscribe from the client (as a mutation) with the graph query of interest (as a parameter). Stash the query (on the client) so that the push notifications know what it is (and still have the component metadata on the query for normalization). You could safely store this in app state, for example. 2. on the server, associate the subscription with the websocket client id 3. Run the query and push the result to the client. The client uses the stashed query to merge/normalize it. 4. On the server, use something like clojure walk to pull out all of the :db/id from the tree of data from (3). Put those in the āwatch setā for that subscription 5. Add a tx log watcher to datomic. If any of those IDs appear in the tx result, repeat (3) and update the watch set in (4) Worked fineā¦there is obviously some polishing from there, but it was surprisingly little code.
Didn't thought about the w alk method
Didn't thought about the w alk method
hey all, are there any resources out there about best practices writing parsers in fulcro? some semi-complicated real world examples would be extremely helpful. Iām a little stuck in the weeds with how to proceed actually building an application using fulcro, as I canāt figure out exactly how to structure my parsers for anything beyond toy applications
for me the video tutorials really helped get a bit of a overview of how work https://fulcrologic.github.io/fulcro/docs.html
I guess my hangup is something like: given that youāre trying to compose all child componentsā queries into a root query, how do you decompose the query in that root read fn in the parser and pass those query fragments down to other parsing functions that can actually service the query fragment?
like for a totally contrived example, say I have some ui components that look like the following:
(defui NavbarSettingsDropdown
static om/IQuery
(query [this]
[:user/email])
Object
(render [this]
(let [{:keys [user/email]} (om/props this)]
(dom/p nil email))))
(def navbar-settings-dropdown (om/factory NavbarSettingsDropdown))
(defui NavbarSignInPrompt
static om/IQuery
(query [this]
[:authentication-request/is-loading?])
Object
(render [this]
(let [{:keys [authentication-request/is-loading?]} (om/props this)]
(if is-loading?
(dom/p nil "Loading...")
(dom/button nil "Sign in")))))
(def navbar-sign-in-prompt (om/factory NavbarSignInPrompt))
(defui Navbar
static om/IQuery
(query [this]
[:something
{:navbar-sign-in-prompt-data (om/get-query NavbarSignInPrompt)}
{:navbar-settings-dropdown-data (om/get-query NavbarSettingsDropdown)}])
Object
(render [this]
(let [{:keys [user/authenticated? navbar-sign-in-prompt-data navbar-settings-dropdown-data]} (om/props this)]
(if authenticated?
(navbar-settings-dropdown navbar-settings-dropdown-data)
(navbar-sign-in-prompt navbar-sign-in-prompt-data)))))
(def navbar (om/factory Navbar))
(defui Body
static om/IQuery
(query [this]
[:something]))
(defui RootComponent
static om/IQuery
(query [this]
[{:body-data (om/get-query Body)}
{:navbar-data (om/get-query Navbar)}])
Object
(render [this]
(let [{:keys [navbar-state]} (om/props this)]
(navbar navbar-state))))
what would my read
fns look like?
I could do something like:
(defmulti read om/dispatch)
(defmethod read :body-data
[env key params])
(defmethod read :navbar-data
[env key params])
(defmethod read :navbar-sign-in-prompt-data
[env key params])
(defmethod read :navbar-settings-dropdown-data
[env key params])
but forwarding the fragments pulled up into the root query down to those other read fns feels a little wrong, and I canāt quite piece together what om/fulcro api methods I might use to assist in that
if anyone has any tips Iād love to hear more@mss: with Fulcro you don't have reads on the client - mutations change the state and your components pick up that state.
The components you have there seem like they are 'one ofs', in which case there is only one ident for each 'class', and using InitialAppState
will be able to get some of the state in place.
I know with Om Next I did have to compose all the components at the root. Or to put it another way when I debugged the state and found something not there I would add that component (get-query MyComponent)
in the root query. Have not needed to do that with Fulcro so far.
interesting. seems like Iām coming at this from the totally wrong mental model since I started by diving into om
Use (dump)
from user namespace to make sure it is all there and normalized properly.