I want to interop with some javascript code. If I did things in javascript, then what I’d want to do would look like this:
var textToSVG
TextToSVG.load("https://myserver.com/myfont.ttf", (err, t2s) => {
textToSVG = t2s; // This is the function I care about getting
});
What I want to get out of this code is the textToSVG function (t2s), but I don’t know how to get it a nice way in clojurescript because the javascript code is not in functional style. One way is like this:
(defonce text-to-svg (atom nil))
(TextToSVG/load
"https://myserver.com/myfont.ttf"
(fn [err t2s]
(reset! text-to-svg t2s)))
Is that what you’d do, or is there a better way?
(edited for clarity)