I'm learning reagent, and I have a doubt: I want to slowly construct a graph during the lifetime of the application, and the graph will be displayed with cytoscape.js
. What should go in a r/atom
? How can I get the external javascript to change the page?
can’t bundlers make many types of transformations as well as add asynchrony when loading modules? it seems like either of those could potentially break find-ns-obj
I mean that's true if you want to eval code that interacts with an existing namespace.
But what if you wanted to have a sort of sandboxed evaluation where the evalled code can't interact with the bundled code?
i suppose there are situations where it might work. my guess is that’s it’s the type of thing where they’re explicitly not intending to offer support for that use case since it could potentially be a rabbit hole
I see. Sad. 😞
Okay, so it sounds like a sandboxed-eval isn't really possible with clojurescript. Thanks anyway. 😞
sand boxing and target bundle isn’t the only possible combination. what’s wrong with producing javascript using the normal target and using one of the available javascript sandboxing options?
if sand boxing is the primary goal, then i think that should be doable
@smith.adriane I'm mostly using the bundle target for npm packages.
Although I have another possible approach. Would it be possible to run two clojurescript programs on the same page?
I have two questions on reagent; the context is that my page displays a graph managed with cytoscape.js
1. I have the entire graph in my r/atom
. However, when the graph is updated, I don't want to redraw all the graph (because to keep positions of the already displayed nodes I want to pass only those to cytoscape). Instead, I want to calculate the diff between what was previously in the atom and my new version, and use that diff to issue the proper command to cytoscape. I cannot figure where to put this logic in the reagent framework, though
If so, then one could be build with bundle and the other the default target and then communicate through websockets or something like that.
2. I want to intercept when a node in my graph is clicked, and put that information in my global atom. But that part of the dom is built by cytoscape. How can I intercept the click events on the nodes?
All these questions should probably be asked in #reagent instead.
Thanks, will ask there!
i’m away from keyboard, but I assume there’s some set up that allows for using npm packages and having sandboxed clojure script eval in the browser.
have you tried shadow cljs? i’m not super familiar with its internals, but it’s integration with npm has been great in my experience and it looks like it support several targets, http://shadow-cljs.org
for sand boxing, i would use one of the tools that focuses on sandboxing js in the browser and using that for your js eval function
unless the sandboxing isn’t security critical, then I would just eval code in its own namespace
@smith.adriane The sandboxing isn't security focused.
Its more just isolation.
And evaling it in its own namespace would 100% be enough, if I could. 😞
But since eval seems to directly call find-ns-obj
it doesn't work with the bundle target. 😞
I have looked at shadow cljs, but IIRC its set to a fixed version of clojurescript
And so I'd be a bit dubious of it working since eval
in older versions of clojurescript seemed to work just fine.
(Mostly because the *target*
variable was pre-set to default
, rather than bundle
.
I'm not sure how that changed though.
Anyway, thanks for your help so far.
another option I would consider to ease the configuration issues is to have two separate js output builds. have one js output with target bundle that runs your application and does most of the work and have a second js build target that exports just the eval functionality that you need with the default target.
Why can I use this in a template:
[:p #{{:id 1 :data "foo"}}]
but not this:
[:p {:foo #{{:id 1 :data "foo"}}}]
It has something to do with the way data is represented in the js side, but I'd like to understand bettersometimes an object is printed as #object[Core [object Object]]
even if I use str
Nevermind my bad, I had a bad type assignment (I need instrumentation 😂)
I’m using .-rep
to view a LocalDate
in transit, but I need to format the result differently. What’s a good way to do that?
First time working with transit, BTW.