Questions tagged [clojurescript-javascript-interop]
53 questions
5
votes
2 answers
How to author agnostic JavaScript library in ClojureScript?
Let's say I have a cljs file containing the following:
(ns foo)
(defn add [x y]
(+ x y))
and wish to make this available as a JavaScript library to non-ClojureScript devs (primarily focused on node.js). I can do this:
clj -m cljs.main -c foo
But…

Jared Smith
- 19,721
- 5
- 45
- 83
4
votes
3 answers
How to I get the body text of a Response object returned by the fetch API in ClojureScript?
I'm trying to use the Github Gist API to get a list of all of my Gists like so:
(ns epi.core)
(.then (.fetch js/window "https://api.github.com/users/seisvelas/gists")
(fn [data] (.log js/epi data)))
js/epi is just console.log except…

Alex V
- 3,416
- 2
- 33
- 52
4
votes
1 answer
Import react-table into ClojureScript with Shadow-CLJS
Web development newbie here. I'm trying to use the NPM react-table package with a ClojureScript/Reagent project. I'm failing to import the package properly. What I've done:
1/installed react-table through NPM, it's in my project directory
2/in my…

alex314159
- 3,159
- 2
- 20
- 28
3
votes
1 answer
ClojureScript cljs.core.async/go doesn't work inside jsdom
I am trying to migrate ClojureScript tests from "Chrome Headless" to jsdom using Karma and shadow-cljs as test runners.
The regular tests which require access to DOM or browser API work fine. But async test where cljs.core.async/go is used doesn't…

Valdermeyder Hussar
- 119
- 7
3
votes
2 answers
Clojurscript: extend a Javascript class
I'm trying to use a particular JavaScript framework which requires extending a base class to use it for application.
Basically I want to do the following as idiomatic ClojureScript.
class Foo extends Bar {
constructor() { super("data") }
…

waechtertroll
- 607
- 3
- 17
3
votes
0 answers
Dynamically generate global vars in a namespace from a list
I'm working on a thin wrapper around a js library and I want to dynamically generate variables from a list for use in other namespaces.
e.g. Given a list of (:foo :bar :baz), I want to dynamically generate:
(def foo (some-fn foo))
(def bar (some-fn…

Ahmed Almutawa
- 51
- 3
3
votes
1 answer
Animate antizer table with rc-animate in re-frame app
I am trying to recreate the example in http://react-component.github.io/table/examples/animation.html to add animation to a table in a re-frame app. The table is rendered using antizer which is a ClojureScript library for Ant Design react…

idyphall
- 31
- 6
2
votes
1 answer
Using ReactNative External library in ClojureScript Project - Syntax
I am trying to use react-native-swipe-list-view inside clojurescript. But I am having some trouble in converting documented js code in cljs code.
Documentations:
import { SwipeRow } from 'react-native-swipe-list-view';
…

hrca
- 458
- 3
- 10
2
votes
1 answer
The required JS dependency "@silvia-odwyer/photon" is not available -- ClojureScript -- Node.js -- npm -- yarn
I am doing the example project https://github.com/minimal-xyz/minimal-shadow-cljs-importing-npm to later add Photon dependency https://silvia-odwyer.github.io/photon/guide/using-photon-web/ and after following the steps I get this warning.
PS…

Fabricio Cozzarolo
- 67
- 6
2
votes
2 answers
How do I open a new window using ClojureScript?
I need to open a new tab using ClojureScript.
(js/window.open "http://localhost/go/somewhere")
I get the following error: Uncaught TypeError: window.open is not a function
It doesn't help setting it because nothing happens and I assume it is…

Clarice Bouwer
- 3,631
- 3
- 32
- 55
2
votes
0 answers
How can I stop the ClojureScript compiler from resolving certain `require`s?
In my ClojureScript code I am requiring a JavaScript module called seedrandom which is in the node_modules folder, like this:
(ns something.core
(:require ["seedrandom" :as rnd]))
(js/console.log (.quick (rnd "x")))
According to the seedrandom…

Chris McCormick
- 4,356
- 1
- 21
- 19
2
votes
2 answers
ClojureScript change display none to visible
I want to modify the visibility of a table when a button is clicked, utilizing clojurescript/javascript interop.
I've tried
{:on-click #(-> js/document
(.getElementById "db-search-result-tables") …

CambodianCoder
- 467
- 4
- 14
2
votes
1 answer
How to keep keywords in arrays when converting to json using js->clj?
My actual behavior is
(js->clj (clj->js [:a :b :c]) :keywordize-keys true)
=> ["a" "b" "c"]
Desired behavior
[:a :b :c]

Jp_
- 5,973
- 4
- 25
- 36
2
votes
2 answers
d3 JavaScript translation to ClojureScript
I want to translate the following JavaScript into ClojureScript:
var myScale = d3.scaleLinear()
.domain([0, 10])
.range([0, 600]);
After creating this function you ought to be able to call it with a number:
myScale(3); // returns 180
My…

Chris Murphy
- 6,411
- 1
- 24
- 42
2
votes
1 answer
Returning value from a javascript callback
I'm having trouble with returning a value from a callback. I'm using https://github.com/transducer/cljs-iota which is a wrapper arounf the IOTA javascript library.
My code is :
(defn find-transactions
"search transactions associated with an…

babouinette
- 21
- 1