This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-19
Channels
- # aws (4)
- # aws-lambda (2)
- # beginners (67)
- # boot (38)
- # cider (32)
- # cljs-dev (12)
- # cljsrn (2)
- # clojars (2)
- # clojure (190)
- # clojure-chicago (1)
- # clojure-dusseldorf (2)
- # clojure-germany (1)
- # clojure-greece (3)
- # clojure-italy (5)
- # clojure-russia (6)
- # clojure-spec (47)
- # clojure-uk (10)
- # clojurescript (59)
- # cursive (9)
- # data-science (14)
- # datomic (24)
- # devops (16)
- # emacs (8)
- # fulcro (25)
- # graphql (30)
- # hoplon (123)
- # juxt (15)
- # lambdaisland (2)
- # leiningen (4)
- # luminus (6)
- # lumo (9)
- # off-topic (11)
- # om (7)
- # onyx (8)
- # re-frame (14)
- # reagent (5)
- # ring-swagger (5)
- # shadow-cljs (46)
- # spacemacs (41)
- # specter (8)
- # testing (8)
- # unrepl (31)
- # yada (18)
I’m not sure if this is fulcro related or not and i’m quite a beginner but i thought i give it a shot.
I set up the leiningen fulcro template to make a few tests and tried to use “sablono” in it.
I added sablono to the list of dependencies in project.clj
(`[sablono "0.8.1"]`) and require it in root.cljc
:
[sablono.core :as html :refer-macros [html]]
.
When i start the server, it can initially render the page with sablono. Every subsequent change or restart of the server yields
Unable to resolve symbol: html in this context
though.
Is there anything missing about the setup of the fulcro template to make the dependency stable?
@alpox This explains your problem: http://www.bauerspace.com/refer-a-macro-with-cljc/
How can I wrap a mutation with another one? Fulcro bootstrap has show-modal
and I'd like to have a mutation that basically wraps it and delegates to it.
I want to detect if modal wasn't initialized
basically I want to fill out init data for modal before each show-modal
I could do it as another mutation and list both mutations in the vector
[(prepare-modal) (show-modal)]
but now I have bunch of mutations with similar parameters and theres a lot of parameter duplication
@roklenarcic If I run into that issue I just extract functions from the different mutationsand create a mutation that composes those mutations together calling the extracted functions.
@roklenarcic What Mitchel suggests is also my suggestion (see Reference Guide). Of course, transact!
itself accepts a sequence, so you can compose them at the UI layer, or behind the scenes at the mutation layer; however, mutations are intentionally structured to not be “nestable”. Nesting creates a lot of incidental complexity. Writing helper functions that accomplish tasks and using those in your mutations is better.
Any State => State
function can easily be composed into a swap!
in a mutation (swap! state #(-> % (do-thing-a params) (do-thing-b params) ...)
I guess the only issue is when a mutation comes for a lib
then I can't break it up into a function
But I'll think of something, maybe a function that puts together the mutation vector
I guess that's one way to do it
So, a library should always be written with composition in mind. For Fulcro they should supply both the mutation, and the helper function that works just on state.
But you’re also correct in that nothing prevents you from writing modal-transact!
that wraps some tx modification with a call to transact!
food for thought: have you considered enabling AST/reads optimizations server-side? This is not something I would need today, but thinking long term, I thought that it might come handy sometime in the future, to be able to optimize DB operations based on the whole query tree. Right now fulcro uses defquery-root
as a point where you implement a read of a single key. But sometimes, you have multiple reads of the same type in or some other reads that can be processed in bulk. Like AST has read for number of people in the database and another key requested list of people with an empty filter. The second operation can also supply data for the first read.
Just something I was thinking about when reading about these kinds of optimizations being done with GraphQL server-sides.
So, the macros are just wrappers for a multimethod. On the server side the base primitive is the Om query parser (which you can in turn further wrap in whatever you want). Many applications will be fine with the macros and built-in parser, but more complex apps can already leverage the primitives instead in whatever way you want.
See also @wilkerlucio’s work on pathom
. He’s done some amazing stuff for building server parsers.
thx I'll look into it