Say I have this remote action:
(remote [{:keys [ast] :as env}]
(let [{:keys [search-params]} (-> env :ast :params)
new-query (eql/query->ast1 `[{[:book/title ~search-params] [:book/author :book/title :book/published]}])]
(-> (assoc env :ast new-query)
(m/returning ::books/Book)
(m/with-target [:author/name "Vladimir Nabokov" :books]))))
I am aware (after consulting the source) that the let is repetitive as m/returning seems to do something very similar. What about this code (apart from its repetition) is incorrect? Why does this not populate anything in app state? All the server-side operations are working as I expect them to. By manually specifying that I want a load to occur (with df/load!), I can get the app state to update. But I obviously misunderstand the purpose/behavior of the remote . How can I reconcile these?ok, don’t mess with the AST manually at all. use the m/x helpers. The AST will already have your mutation name and params. IF you need to change the server symbol or params use the helpers like with-server-side-mutation. The returning/target combo are indicating the query for normalization of a return value from the mutation…but of course the mutation must at LEAST return the ID of the entity, so that pathom resolvers can run to flesh out the graph of that item.
The other thing to consider is that IF your mutation changed the database, can the resolvers SEE the updated database? E.g. if you were using Datomic and had a db in the env on the server, that db would not have changed from a transact.
So, if this books/Book component uses :book/id, then I would expect the server-side mutation to be something like:
(pc/defmutation foo [env params]
{::pc/output [:book/id]}
...
{:book/id some-id})
and I’d expect that you’d have other resolvers that have :book/id as INPUTs and the remaining data of interest as OUTPUTsI was doing something very foolish indeed. I created this mutation to update the UI locally but then I was trying to shoehorn a load in, but to a separate component than the one that triggered the mutation. Removing the remote and doing things with df/load! works fine. Thanks for the explanation!
(I wasn't really mutating anything on the server)
I am trying to coax a graphviz dot file from my statechart using https://github.com/daveray/dorothy . I have it almost working. Something is not clicking for me on translating the tree to nodes and edges. Code is in this toy project: https://github.com/michaelwhitford/bb-statecharts I feel like I am missing a fundamental about the data structures and their relation. Any help is appreciated.
funny…. @yaw556 and I are working on a statechart rendering thing using mermaid right now
(want it for inspect, to show the current state, etc as an inspection tool)
I made this bit of code that outputs an xstate chart for simulating in xstate viz…very alpha and possibly incomplete, but perhaps it would help: https://gist.github.com/awkay/3fc8b9e837f70904b9404bee3635b3a3
My goal is to instrument the statecharts lib so it can talk to Fulcro Inspect. Then you could use the electron version for CLJ and the browser version on web pages that use charts. Ideally this would work without requiring Fulcro itself, just the preload that installs the inspect hooks for communcation.
So I’m aiming for an Inspect tab where the current state(s) can be visualized, and even show transitions as they happen with some history and such.
Just to be clear I am running this code from clojure, not bb. I am trying to have my code run from both, but currently am only running it under clojure to get the base case working.
@michael819 this looks interesting. We have a working WIP repo using MermaidJS https://github.com/yoodame/statechart-diagram. I just merged @tony.kay’s PR which leverages multi methods on the node-type to build the chart tree. Perhaps there're some nuggets in there to help you on your path? At the moment, lib outputs mermaid's state diagram syntax. You can paste it into their https://mermaid.live/edit#pako:eNpNTztvgzAQ_ivWjRUgGxOn56FT10zZWnewwAEksJGxo6aI_16HtLTT3fe4x7dA7RoDEuagg3ntdev1mF9LZd-fPkiev5A59MOg7FY2YnTX3rZEkinOnbI_cLduwn3in1B7PXf7xAPd-XQDMhiNH3XfpCcWZQlREDozGgUytY256DgEBcquyapjcOebrUEGH00G3sW2A3nRw5xQnJq_EL8W0_TB-dMj5RY2g0nbN-d2S4IgF_gEyQQtsETOOSIyVooMbol9rgqGB0oZHoUQRyzXDL62BbQQyCte0QMKhki5WL8Ban1qIA to render the nodes.
Thank you both for the pointers, I am studying and playing with this code to try to wrap my head around the structures. I am using dorothy and a dot file because my command-line program is not clojurescript, it will run under clojure and bb only, so I looked for a solution that would work in those environments. My plan is to have to generate the dot file, and then my deploy CI will use graphviz to generate the diagram when the statechart changes in the repository.
great