This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-03-12
Channels
- # aleph (10)
- # beginners (62)
- # boot (12)
- # cider (97)
- # cljs-dev (171)
- # clojars (1)
- # clojure (224)
- # clojure-italy (4)
- # clojure-nl (2)
- # clojure-russia (1)
- # clojure-spec (41)
- # clojure-uk (68)
- # clojured (7)
- # clojurescript (115)
- # community-development (4)
- # cursive (2)
- # data-science (1)
- # datomic (18)
- # duct (40)
- # emacs (1)
- # events (1)
- # fulcro (148)
- # funcool (2)
- # graphql (2)
- # immutant (3)
- # jobs (3)
- # keechma (1)
- # luminus (2)
- # numerical-computing (1)
- # off-topic (19)
- # om (6)
- # parinfer (10)
- # pedestal (15)
- # precept (86)
- # reagent (12)
- # ring (3)
- # ring-swagger (2)
- # shadow-cljs (42)
- # spacemacs (19)
- # specter (17)
- # sql (11)
- # tools-deps (78)
- # unrepl (62)
- # vim (28)
I have been doing some electron work in plain JS recently — one side is the “server” side which is Node with some extra electron APIs you require
. The other side is the client side with also some extra APIs. I think it could be treated as just two separate targets…
Would anyone else also find it useful to be able to specify a vector of functions for :before-load
and :after-load
in devtools options?
I end up making on-reload!
functions which only exist to trigger cleanup/reset behaviour from namespaces which have no other relationship to each other
IIRC you are able to require
the electron APIs from both sides, but the browser side gets access to the “remote” part of that.
I’m not sure how that works, but for shadow to do its thing you should just be able to expose a require
function, no?
@mhuebert I could certainly add that but it sounds like you have some global state that needs refreshing? global state is tricky when it comes to reloading.
@orestis either way you can definitely build something with shadow. if require is possible you might get away with one build instead of two though.
@thheller the 3 things I currently do on reload are (1) clear a global error state which is set when a react component throws, (2) re-render react component tree from root, and (3) I have a logging lib which uses logging groups, and open groups need to be closed on refresh
I’ll have to check and see what the assumptions are — because one side is definitely no-browser, whereas the other side yes-browser.
@thheller I think if i would clear the error state before load, that would trigger a re-render before the new (possibly-fixed) views have been loaded
and just calling the other on-reload!
fns directly from your one on-reload!
doesn't work?
that does, it was just mildly awkward because i didn’t have any existing namespace which could require all of the namespaces which had functions to be called
so i had to create a separate thing in a utility library which all of these namespaces could then require, and register on-load functions
eg
(defonce on-reload* (atom {}))
(defn on-reload
"Register a callback to fire when page reloads (during development)"
[key f]
(swap! on-reload* assoc key f))
(defn reload!
"Fire registered reload callbacks"
[]
(doseq [f (vals @on-reload*)]
(f)))
the trouble with a vector of multiple :after-load
fns is that it can't control async
I was thinking about this zero-conf stuff a bit. we could certainly have some other ways to configure these hooks
as a library author, if someone uses re-view
it would be nice to say “and add re-view.render-loop/render
to your :after-load
option”
compiler could even be smart and just ignore those fns when compiling release builds
i guess the downside is that for a library that is less good, as you don’t want to impose specific tooling on users. not that metadata imposes it, but you don’t want (defn ^:shadow/after-load , ^:figwheel/after-load ...)
(*I can’t remember what metadata figwheel all uses, i remember something like ^:figwheel-always
)
I think this is only an issue with global state though which you shouldn't have in the first place 😛
seems there're two styles for configuration for clojure now lein style
and tools.deps style
: paths
vs source-paths
, deps
vs dependencies
, repos
vs repositories
. will it be a good idea to support both or insisting on the lein style
or just like user use tools.deps
with shadow-cljs
?
@doglooksgood don't know about allowing two different styles in shadow-cljs.edn itself but maybe