clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
p-himik 2021-02-09T06:21:50.080800Z

Good call. :) See, the demo version of the library above cannot access your folders - it requires you to either paste the data directly or click on the "Choose File" buttons. I'm pretty sure you have only three options here: - Create a full-fledged backend. The server will have access to your file system and the frontend will be able to display it - Create a desktop app. Same as above but with GUI instead of WUI - Create a CLI app that will generate a static HTML and maybe automatically open it in a browser

dazld 2021-02-09T11:13:28.082400Z

I'm sure this comes up all the time, but I couldn't find a simple explanation - by what process can I get output of prn/`pprint` etc in my repl, and not the browser console? I guess something has intercepted this..?

p-himik 2021-02-09T11:15:55.082500Z

By default they should print out in your REPL. The redirection to the browser console is usually done explicitly by calling (enable-console-print!).

p-himik 2021-02-09T11:21:27.082700Z

So either that function is called somewhere in your code or it's called by something in your setup. Or maybe the print function is set directly with set-print-fn!. In any case, the answer to your question depends on your setup and your code. Impossible to say anything without knowing about those two.

dazld 2021-02-09T11:26:41.082900Z

thanks @p-himik - assuming something is calling this, is there a way to get the current repl as a print target to override that call later?

p-himik 2021-02-09T11:28:15.083100Z

There is, by calling set-print-fn! yourself. There's also set-print-err-fn!.

p-himik 2021-02-09T11:28:43.083300Z

And you might also want to (set! *print-newline* true).

p-himik 2021-02-09T11:29:20.083500Z

The value that you have to pass to those set-*-fn! functions depends on your particular REPL. The default CLJS browser REPL that you start with cljs.main uses clojure.browser.repl/repl-print.

πŸ‘ 1
dazld 2021-02-09T11:47:19.083800Z

having a play, thanks a ton!

πŸ‘ 1
dazld 2021-02-09T11:49:26.084100Z

I guess shadow has its own location for the repl - clojure.browser.repl/repl-print appears to be undefined

dazld 2021-02-09T11:49:35.084300Z

i'll go check the docs.

p-himik 2021-02-09T11:54:20.084500Z

Huh, shadow-cljs prints in both places for me.

dazld 2021-02-09T12:02:55.084700Z

that would be ideal

dazld 2021-02-09T12:04:09.084900Z

(prn :hi) from the repl, prints to the repl and the browser, this is great

dazld 2021-02-09T12:04:24.085100Z

the same from within, say, a reagent component or function, only prints to the browser

dazld 2021-02-09T12:10:55.085300Z

thanks - i'll go ask in the shadow channel.

thheller 2021-02-09T13:24:51.085500Z

use (with-out-str (pprint foo)) to get the string

thheller 2021-02-09T13:25:07.085700Z

oh nvm

πŸ˜‰ 1
fsd 2021-02-09T20:24:09.095400Z

Hello there, I am having little problem, So I have array of :tasks [{:unitid 1} {:unitid 2}] and so on, which is pulled from api and stored as state. How do I add more objects into this ? I tried doing the following but it just overrides it. I tried doing (swap! State* assoc :tasks {:test 1} ) Result is :tasks {:test 1} Can someone please tell me what’s going on? I would like my results to be :tasks [{:unitid 1} {:unitid 2} {:test 1} ]

dpsutton 2021-02-09T20:28:00.098600Z

ignore the atom. assoc takes a map, a key, and a value and returns the map with that key value pair added to it. (assoc {:a :b} :a :new) will return {:a :new}. If you want to modify a map as you're intending you want to use update. In this case (update {:a [:b]} :a conj :new) will yield {:a [:b :new]}. Putting this together with the atom functions: (swap! State* update :tasks (fnil conj []) {:test 1}) should do what you want. I'm using fnil to handle if there's not already a value present with that key to use [] instead of nil

fsd 2021-02-09T21:03:10.099Z

Thank you so much it worked

1