This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-02-02
Channels
- # announcements (1)
- # babashka (6)
- # beginners (53)
- # cider (2)
- # circleci (2)
- # clj-kondo (1)
- # cljdoc (1)
- # clojars (2)
- # clojure-berlin (1)
- # clojure-europe (23)
- # clojure-serbia (1)
- # clojure-spec (2)
- # clojure-uk (9)
- # clojurescript (12)
- # datomic (34)
- # emacs (1)
- # fulcro (46)
- # leiningen (15)
- # planck (3)
- # re-frame (46)
- # reitit (17)
- # remote-jobs (4)
- # shadow-cljs (17)
- # sql (3)
- # tools-deps (2)
Is there anything wrong with my setup, or recomplilation of defmutation
(server side) does not have immediate effect?
@slawek098 you probably want some kind of “reloaded” workflow. Look at the Fulcro template for a straightforward example of how to set this up with mount (although you can also use component or some variant if that’s your preference). Using this workflow, when I make a change I first reload the namespace (to make sure it compiles) then restart the system, by running (restart) at the REPL if you’re using the same setup as the Fulcro template. Also note that in Cursive or Emacs (and probably other editors) you can bind the reload command to a keyboard shortcut, so it’s really quick to do this as part of your normal development workflow.
@mdhaney I am using component
, so (reset)
fixes everything - but I am surprised that redefinition of function in runtime does not resolve the issue.
Yeah, I think there are a couple things going on there. I remember reading something about Ring and how handlers wouldn’t pick up changes without special steps being taken, and also something about the way Clojure deals with multimethods. TBH, I’ve been using the reloaded pattern so long, I’ve forgotten the details of some of the problems it was trying to solve. ☺️
A problem is if you pass a fn by value (the default) - changing the original fn's code then of course has no effect, that's why you typically give #'my-handler to ring. Mulrimethods, protocols etc are troublesome.
which reactjs widgets do you use with fulcro, folks ?
1. Preferably you map the (reset)
to a keybinding in your editor.
2. When I was still using boot
, it had a watch
filesystem task, and it was easy to run reset from there.
3. You could always e.g. add a ring middleware, so in dev-mode each new HTTP request refreshes your reloadable code
I've found that with bigger component systems (and access to current state in the repl), I don't actually like it reseting with every file save, so I use (1) - in emacs via .dir-locals.el
ah, ok; well if it's just a question of defmutation
, if you avoid caching your mutations/resolvers within a var (i.e. use defn or #'reference) and create new pathom parser with each request, that should work without (reset)
you want to be able to update a mutation’s body and eval it and have your system use that new version, correct?
if you re-eval the add-connector
it's not going to be refreshed in the parser, because the var is cached
if that’s what you want, you can make a wrapper macro for defmutation, make it output a defn
with a stable name and invoke that internal function in the mutation body
that’s what we’ve done in our project
@U09FEH8GN wouldn't it be enough to reference it via #'add-connector
?
but we (@U0CKQ19AQ and I) also strongly recommend test driven development on the server, rather than manual trial-and-error driven development
@pithyless i’m not sure what you mean
"class clojure.lang.ExceptionInfo: Mutation not found - {:mutation wires.mutations/add-connector}"
@slawek098 doesn't the reloaded workflow have any way to keep some state (your Datomic) across reloads?
or you could make a source dir that has your db in it, and the elide that dir from the call to set-refresh-dirs
There is http://clojure.github.io/tools.namespace/#clojure.tools.namespace.repl/disable-reload! - or just set the Metadata on the ns manually
I reload the defmutation namespace and the pathom parser namespace (I don’t need to reload the whole app). I use mount
for state management and it automatically reloads the pathom state component when the file is recompiled.
@pithyless @slawek098 this is how we wrap mutations and resolvers https://gist.github.com/currentoor/dce7e45a38563452c379c510be63f0a3
we also have some authorization/permission stuff mixed in there
that NS is used by JVM and nodeJS envs
the JVM one has the internal function trick so you can re-eval a mutation definition and have it take affect immediately