This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-10-28
Channels
- # beginners (45)
- # boot (4)
- # cider (5)
- # cljs-dev (8)
- # cljsrn (4)
- # clojure (38)
- # clojure-conj (7)
- # clojure-dev (4)
- # clojure-russia (3)
- # clojure-spec (20)
- # clojure-uk (3)
- # clojurescript (28)
- # core-logic (29)
- # figwheel-main (10)
- # fulcro (2)
- # onyx (1)
- # other-languages (5)
- # parinfer (3)
- # pathom (98)
- # portkey (1)
- # reagent (15)
- # reitit (9)
- # shadow-cljs (22)
- # spacemacs (10)
- # sql (22)
- # tools-deps (1)
Give ClojureScript master a spin with your day-to-day work this week. All show-stoppers have been fixed and a release will be cut soon.
Building and using master: https://clojurescript.org/community/building
I got atoms with data :string1 :string2 and I want to call clj-ajax/POST but I cannot get it to work. curl calls work fine. Everything I google says to use :params and :format :json but thats not working for me.
Hey guys! Another follow up to my code splitting question. I have a browser extension written in clojurescript. Looks like this
worker/
| -- core.cljs
safari/
| -- browser.cljs
chrome/
| -- browser.cljs
browser.cljs
contain the browser specific abstractions to interact with it. Like getting settings and so on.
Currently browser.cljs
are all having the namespace myextension.browser
. During build, I use cljsbuild
say that for build target chrome
, it should use chrome/
and worker/
as source paths.
Inside core.cljs
I can then just require myextension.browser
like I would always do.
Now I am trying to port this to the cli to get familiar with it, but have my issues replicating this kind of setup. Module splitting says I could just use :modules
and emit multiple modules, then let them include each other, but since all the browser abstractions have the same namespace, this seems a little more difficult
One idea was to maybe just export
a node/require style package and use that inside my core.cljs
, but if possible I'd really like to solve this in cljs aloneIt would be great if I could keep the abstractions on separate namespaces like myextension.safari.browser
, then have a myextension.safari.core
entrypoint that uses that, but the code that I share between all the extensions needs functions defined inside the browser
package
Without import magic, myextension.safari.core
should import myextension.safari.browser
, then tell myextension.common
to use that package
@dvcrn I think you’ve already come up with the solution; you need to invert the direction of your dependencies
so myextension.common
should be a dependency that the safari, chrome, etc. modules bring in
I’m not sure that module splitting is the best tool for this. I’m not sure what you mean by > port this to the cli
I am having trouble with boot-reload in my clojurescript project. I am storing the game state in an atom. I want the game to reset to the starting state upon reload. The game loop uses setInterval to make a timer. When my code reloads it seems to wipe out the game state before calling my function that I set with on-jsload and that makes me lose track of the timer. Is there a way to run a function to clear the game state before reloading?
you mean how I currently do it in cljsbuild?
During build I tell it to use safari/browser
+ worker/
for Safari builds,
For chrome I do chrome/browser
+ worker/
and so on
x/browser
is always a implementation of myextension.browser
currently, so multiple files have the same namespace, but on build it's only using one of them
doing this via cli & deps, you can just have aliases refer to different parts of classpath for your different builds
(deftype State [react-ref]
IDeref
(-deref [_]
(first react-ref))
IReset
(-reset! [_ v']
((second react-ref) v')
v')
ISwap
(-swap! [o f]
(-reset! o (f (-deref o)))))
(def foo (State. ["foo" (fn [_] (println "reset"))]))
(swap! foo identity "bar")
Error: No protocol method ISwap.-swap! defined for type hooks-demo.hooks/State: [object Object]
With some help from the #boot channel I figured out my problem. I needed to create my atom with defonce
instead of def
.
Can you share a snippet or screenshot of what you're talking about specifically
(hx/defnc Display [_]
(let [{:keys [name count]} @(<-context state-context)]
(hx/c [:div name ": " count])))
Can you share a snippet or screenshot of what you're talking about specifically