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
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..?
By default they should print out in your REPL. The redirection to the browser console is usually done explicitly by calling (enable-console-print!)
.
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.
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?
There is, by calling set-print-fn!
yourself. There's also set-print-err-fn!
.
And you might also want to (set! *print-newline* true)
.
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
.
having a play, thanks a ton!
I guess shadow has its own location for the repl - clojure.browser.repl/repl-print
appears to be undefined
i'll go check the docs.
Huh, shadow-cljs prints in both places for me.
that would be ideal
(prn :hi)
from the repl, prints to the repl and the browser, this is great
the same from within, say, a reagent component or function, only prints to the browser
thanks - i'll go ask in the shadow channel.
use (with-out-str (pprint foo))
to get the string
oh nvm
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} ]
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
Thank you so much it worked