This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-04-22
Channels
- # admin-announcements (7)
- # beginners (56)
- # boot (69)
- # cider (168)
- # cljs-dev (2)
- # clojure (170)
- # clojure-austin (25)
- # clojure-beijing (3)
- # clojure-belgium (2)
- # clojure-france (3)
- # clojure-poland (17)
- # clojure-russia (115)
- # clojure-uk (40)
- # clojurebridge (3)
- # clojurescript (87)
- # cursive (9)
- # datomic (30)
- # dirac (18)
- # editors (3)
- # emacs (14)
- # hoplon (195)
- # immutant (14)
- # jobs (3)
- # jobs-discuss (4)
- # leiningen (11)
- # melbourne (5)
- # mount (42)
- # off-topic (5)
- # om (24)
- # onyx (48)
- # parinfer (53)
- # proton (1)
- # protorepl (2)
- # re-frame (3)
- # reactive (2)
- # reagent (29)
- # rum (5)
- # spacemacs (4)
- # untangled (91)
- # yada (1)
@telent: In your -equiv
impl above, consider =
instead of ==
. (The later is for nums.)
anyone have much experience with using http://cljsjs.github.io/ to managing including javascript packages?
specifically, i add the [cljsjs/google-platformjs-extern "1.0.0-0”] as a dependency, and require it like (:require cljsjs.google-platformjs-extern)
but get a
No such namespace: cljsjs.google-platformjs-extern
as noted here: https://github.com/cljsjs/packages/tree/master/google-platformjs-extern
@trgoodwin: "This package only contains the externs file. You need to provide the read code yourself."
@trgoodwin: my guess is that you need to include the platform.js file in your source path somewhere. @juhoteperi can probably answer this best.
@trgoodwin: @pastafari: The readme is incorrect, extern is always used and no require is needed.
thanks @juhoteperi. is there a reason the google-platform is just the extern, and not including the actual dependency
i thought that was part of the value of https://cljsjs.github.io
@trgoodwin: The code is only available from google cdn and is not versioned. Google might change the code any time.
And I presume that Google assumes that everyone is using the latest code. Even if the package was updated daily, apps would depend on old version and might break.
@juhoteperi: ah. i see. think that makes sense. so basically unless you can pin, you don’t include.
@juhoteperi: couldn’t the cljsjs/packages pin based on date when building jar.
Yes, but then app would use certain version which might break.
I don't think Google promises that the version from today would work in two months
They might change some APIs the code is calling etc.
so if i understand it right. its more there is no way to know when change happens, therefore no way to know when to create a new jar
Not exactly. We could easily package the code each night if it has changed.
But if we package version 2016-04-22 and an application uses that version, it might be that in one week Google updates the code and old code will stop working.
Then the application has to be updated.
But if you just use the script tag with url pointing to google url, your application doesn't need to be updated.
right. so thats where i got confused. because i expected the cljsjs/package to bring the dependency down with it so that i wouldn’t need to use the script tag to include
i think i understand. the current setup is trying to respect more of the existing google stand of always use our latest
Google Maps package is the same
and if they actually changed their api, you’d have to update the externs and create a new package
Anyone have any good tips for Isomorphic OM CLJS rending on the server. Found the following, but thought I would see if anything else is out there: https://github.com/pupeno/prerenderer
@dimiter: check this for om https://github.com/arohner/foam
and https://github.com/ladderlife/cellophane for om next ( WIP iirc )
Speaking of OM Next. Can I use OM Next and The legacy OM syntax in the same app, or do I have to stick to OM-next defui components.
is it possible to define an app-util file that requires macros from another library and exposes them?
for example, with cljs.test …
(ns testing-util.core
(:require [cljs.test :as t :include-macros true]))
(defn deftest [& args]
(apply t/deftest args))
@lwhorton: it is, but you can’t use apply
with macros
@lwhorton: if you want to “apply” to a macro you’ll need another macro
(defmacro deftest’ [& args]
`(t/deftest [email protected]))
all I really want to do is house the exposed cljs.test macros with my functions that are just better-named
(ns testing-util.core
(:require [cljs.test :as t])
(:require-macros [cljs.test :as tm :refer [deftest testing is are]]))
(def deftest deftest)
(def testing testing)
(def is is)
(def are are)
(defn when- [desc body]
(testing desc body))
(defn given- [desc body]
(testing desc body))
(defn it- [desc body]
(testing desc body))
so I can require a single [testing-util.core] and be on my merry way with given- when- it-
so what’s the problem you’re having?
for example, with the above ^ and an implementation test:
(deftest test-test
(given- "something is truthy"
(when- "the first arg is true"
(it- "should also be true"
(is (= true true))))))
What if you don’t refer the cljs.test stuff, and just use namespaced symbols like (def deftest tm/deftest)
? Does that work?
i would assume this is because the call in test-test to deftest is reaching to testing-util.deftest, which is 1) proabably circular reference via (def deftest deftest)
?
or can you do that with macros?
No such namespace: tm, could not locate tm.cljs, tm.cljc, or Closure namespace "" at line 8 test/cljs/testing_util/core.cljs
so unless there’s a way to rename macros on import, then (def deftest renamed-deftest)
i’m not sure what to do
Hmm, what about (def deftest t/deftest)
? I don’t know nuthin about cljs macros really, but I’d give that a try just to see what happened
hm, even with :require [cljs.test :as t :include-macros true]
the def deftest t/deftest
complains: Can't take value of macro cljs.test/deftest at line 7 test/cljs/testing_util/core.cljs`
I guess that makes sense
@lwhorton: this works:
(defmacro deftest' [name & args]
`(cljs.test/deftest ~name [email protected]))
put that in a .clj file
in your .cljs file, do:
(:require [cljs.test :refer-macros [is run-tests]])
(deftest' my-test (is true))
(run-tests)
Ran 1 tests containing 1 assertions.
0 failures, 0 errors.
FWIW, so does this:
(defmacro deftest' [& args]
`(cljs.test/deftest [email protected]))
Hello! Are these the same?
JS: m.dragging.disable();
CLJS : (.disable (.dragging m))
Excellent, thank you!
I am sure there is a better way than to repeat (when). Any ideas? Thanks guys!
...
(let [m (.map js/L $e)]
...
;;Disable drag and zoom handlers
(when (false? dragging) (.disable (.-dragging m)))
(when (false? scroll-wheel-zoom) (.disable (.-scrollWheelZoom m)))
(when (false? touch-zoom) (.disable (.-touchZoom m)))
(when (false? double-click-zoom) (.disable (.-doubleClickZoom m))))
I though of (cond false? dragging ... scroll-wheel-zoom ... ...)
but then when the first condition is met it'll stop doing side effects, which I don't want...
@leontalbot: I don’t really see a problem with a bunch of when
s if you need them. (when (false? …))
could be written (when-not …)
in this case it seems to me.
@dnolen: Thank you! Regarding when-not
I don't use it so that if one arg like dragging
is not explicitly set to false (in other words, if nil) the according side effect won't happen...
Trying to figure out the proper interop to reconstruct this JS. Does (set! js/player (.Player js/YT "player", (clj->js {...})))
Work the same?
// YT is a global scope variable
player = new YT.Player('player', {
height: '390',
width: '640',
videoId: 'M7lc1UVf-VE',
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
You should be able to do
(js/YT.Player. "player", (clj->js {...}))
That did it, thanks @taylor.sando!