This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-15
Channels
- # asami (6)
- # babashka (74)
- # babashka-sci-dev (164)
- # beginners (50)
- # biff (3)
- # calva (71)
- # clj-kondo (4)
- # cljdoc (39)
- # cljsrn (4)
- # clojars (8)
- # clojure (70)
- # clojure-austin (7)
- # clojure-czech (5)
- # clojure-europe (4)
- # clojure-losangeles (1)
- # clojure-nl (10)
- # clojure-norway (1)
- # clojure-uk (3)
- # clojurescript (38)
- # community-development (18)
- # cursive (129)
- # datomic (9)
- # fulcro (7)
- # graalvm (4)
- # improve-getting-started (1)
- # jobs (1)
- # kaocha (2)
- # liberator (9)
- # lsp (22)
- # malli (3)
- # membrane (95)
- # off-topic (86)
- # releases (2)
- # sci (5)
- # specter (2)
Usually it's rather hard to find answers for such questions. But if you have a specific problem with integrating the library into your app, it should be easy to help. Also, Reagent repo has multiple examples of integrating other libraries - at the end of the day, it all works in a similar way.
Also, please avoid cross-posting to other channels. I see that you've also asked it in #reagent - that should've been the only place since it's not really relevant to anything else.
import ReactDOM from 'react-dom';
import * as React from 'react';
import createEngine, { DiagramModel, DefaultNodeModel, DefaultLinkModel } from '@projectstorm/react-diagrams';
import { CanvasWidget } from '@projectstorm/react-canvas-core';
var engine = createEngine();
var model = new DiagramModel();
var node1 = new DefaultNodeModel('Node 1','rgb(0,192,255)');
node1.setPosition(100, 100);
let port1 = node1.addOutPort('Out');
var node2 = new DefaultNodeModel('Node 2', 'rgb(192,255,0)');
let port2 = node2.addInPort('In');
node2.setPosition(400, 100);
model.addAll(node1, node2);
engine.setModel(model);
ReactDOM.render(
<CanvasWidget engine={engine} />,
document.getElementById('root')
);
(ns ttt3.core
(:require ["react-dom" :as react-dom]
["react" :as react]
["@projectstorm/react-diagrams$default" :as createEngine]
["@projectstorm/react-diagrams" :as rd :refer [DefaultLinkModel,
DefaultNodeModel,
DiagramModel]]
["@projectstorm/react-canvas-core" :refer [CanvasWidget]]))
(defn doit []
(let [engine (createEngine)
model (DiagramModel.)
node1 (doto (DefaultNodeModel. "Node 1" "rgb(0,192,255)") (.setPosition 100 100))
port1 (.addOutPort node1 "Out")
node2 (doto (DefaultNodeModel. "Node 2" "rgb(0,192,255)") (.setPosition 400 100))
port2 (.addOutPort node2 "In")]
(.addAll model node1 node2)
(.setModel engine model)
(react-dom/render
(react/createElement
CanvasWidget
#js{:engine engine})
(js/document.getElementById "app"))))
(defn ^:export init []
(doit))
In cljs version I get an error: `Uncaught TypeError: a.default is not a constructor at l.componentDidMount (index.umd.js:16)`
Check that the things you're importing are the things you expect. Especially those three models, because those are the ones you're using as a constructor.
Also, if you use :as rd
you don't have to then use :refer
- just use rd/DiagramModel
for example.
Given a set of TypeScript interfaces that I need to implement to have my plugin work in their system: How can implement them in ClojureScript?
This plugin is going to be situated heavily in the ClojureScript ecosystem (Pathom queries mostly). Also, not-a-JavaScript-dev
Pretty sure you just need to have the right methods and members on the object that you return as an instance of the plugin.
If you're using shadow-cljs, the easiest way to do it would be via shadow.cljs.modern/defclass
.
I am following the example here: https://clojurescript.org/guides/promise-interop#using-promises-with-core-async. But seeing errors,
TypeError: undefined is not an object (evaluating 'cljs.core.async.interop.p__GT_c')
The code is
(ns simple.example
(:require
[cljs.core.async :refer [go]]
[cljs.core.async.interop :refer-macros [<p!]]))
(go
(println (<p! (js/Promise.resolve 42))))
If it's an old one - consider upgrading.
Also, note that :refer-macros
is not needed in this case, you can just use regular :refer
or :as
in this case due to how cljs.core.async
namespaces are structured.
That looks like a version of shadow-cljs - that's separate from the version of clojurescript. When using shadow-cljs, make sure that clojurescript comes from its classpath - don't declare a dependency on clojurescript yourself, and make sure that no other dependency does that.
Same with cljs.async - as listed here: https://shadow-cljs.github.io/docs/UsersGuide.html#failed-to-load
Also note that you can use clojure.core.async
instead of cljs.core.async
- makes the code more cross-platform. The required code will be the same - CLJS simply has an internal alias for clojure.core.async
.
Can you create and share a minimal reproducible example? I can't reproduce it locally.
I took a peek at the instructions for clojurescript here https://clojurescript.org/guides/quick-start
Is there a reason that they aren't unified for window Linux and osx?
Why do Windows users need to download the cljs.jar file? Won't something like deps.exe works with the deps.edn?
the instructions are from a time where clj didn't exist on windows. guess no one has updated them yet.
Out of interest, just tested on Windows - seems to be working just fine with clj
and without a standalone JAR.
Yes it also works with deps.exe
just tested it also 😛
But also clj
on Windows is still in the alpha state, so that might be a reason for why it's not mentioned.
@U2FRKM4TW i'd really recommend deps.exe instead: https://github.com/borkdude/deps.clj
it's a standalone .exe file you download instead of the powershell mess
Ah, I'm on Linux so I don't really care. :D The default clj
script works just fine for me.
well i use windows as a daily driver but i hate powershell with all my heart. cmd.exe until hell freezes over

I wanted to use the static instance https://google.github.io/closure-library/api/goog.net.cookies.html, but requiring
result in the following error: The required namespace "
Requiring [goog.net.cookies :as gcookies]
removes this error. However, when I put gcookies
in the REPL, it says Use of undeclared Var .../gcookies