This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-06-28
Channels
- # admin-announcements (2)
- # alda (5)
- # arachne (4)
- # beginners (49)
- # boot (92)
- # capetown (3)
- # cider (9)
- # cljs-dev (6)
- # cljs-edn (1)
- # cljsjs (29)
- # cljsrn (4)
- # clojure (65)
- # clojure-android (1)
- # clojure-berlin (2)
- # clojure-chicago (2)
- # clojure-gamedev (2)
- # clojure-greece (11)
- # clojure-india (1)
- # clojure-japan (1)
- # clojure-new-zealand (2)
- # clojure-quebec (2)
- # clojure-russia (49)
- # clojure-spec (73)
- # clojure-uk (38)
- # clojurescript (118)
- # clojutre (4)
- # community-development (17)
- # cursive (3)
- # data-science (1)
- # datascript (1)
- # datomic (17)
- # emacs (6)
- # euroclojure (2)
- # events (2)
- # immutant (30)
- # keechma (11)
- # leiningen (4)
- # luminus (2)
- # off-topic (19)
- # om (14)
- # onyx (28)
- # planck (9)
- # re-frame (11)
- # reagent (35)
- # ring-swagger (4)
- # schema (4)
- # slack-help (6)
- # spacemacs (2)
- # specter (11)
- # testing (4)
- # untangled (88)
- # utah-clojurians (2)
- # vim (2)
- # yada (9)
So, I’m probably missing something real basic, but brand new to js interop. How do I tell what a library packaged by cljsjs is named?
(ns my.name.space
(:require [cljsjs.showdown]) ; note, no :as or :refer here
(defn convert-to-html [markdown]
;; note the syntax below: js/VarFromExternsFile.property
;; the dot on the end is the usual Clojure interop syntax: (Constructor. constructor-arg constructor-arg)
(let [converter (js/Showdown.converter.)]
;; methods you call will generally need to be called out as prototype values in the externs
(.makeHtml converter markdown)))
I saw this in the example, but wondering if I should just be guessing, or if there is a smarter way
it has the same name as if you'd just add a script take with the file to your HTML
so js/pdf
if I read that stackoverflow answer right
Most libraries export some global, jQuery exports $
and jQuery
, React exports React
and so on
pdf()
= (js/pdf)
The exported globals can be accessed via the global Javascript namespace js/
to do something like this
PDFJS.getDocument('/files/tizenfordummies.pdf').then(function(pdfFile) {
var pageNumber = 1;
pdfFile.getPage(pageNumber).then(function(page) {
var scale = 1;
var viewport = page.getViewport(scale);
});
});
this seems to 1) create a js object, 2) call .then on it, which takes another function, which is passed pdfFile, upon which you call .getPage, to return an object, on which you call .then, and pass a .getViewport
is this relevant? https://groups.google.com/forum/#!topic/clojure/PD3YTY9qoj0
(-> (.getDocument js/PDFJS "/onlisp.pdf")
(.then (fn callback1 [pdfFile] (.getPage pdfFile 1))))
k, found a good example of interop using reagent and a js lib here https://github.com/timothypratley/leaderboardx/blob/a04d424f505bd5270da7a3905af8a6ccf73ae48f/src-cljs/algopop/leaderboardx/app/views/d3.cljs
@conaw: consider asking interop related questions in #C03S1L9DN, much more people there than here 🙂
nah, I don't mind, just didn't see it until now 🙂