This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-24
Channels
- # announcements (12)
- # aws (11)
- # babashka (1)
- # beginners (73)
- # cider (4)
- # clj-kondo (2)
- # cljsrn (4)
- # clojars (2)
- # clojure (68)
- # clojure-europe (8)
- # clojure-nl (5)
- # clojure-spec (6)
- # clojure-sweden (1)
- # clojure-uk (29)
- # clojurescript (41)
- # conjure (22)
- # datomic (33)
- # docker (58)
- # duct (3)
- # emacs (8)
- # events (1)
- # expound (3)
- # figwheel-main (5)
- # fulcro (33)
- # graphql (2)
- # kaocha (2)
- # lambdaisland (39)
- # leiningen (1)
- # nrepl (49)
- # nyc (1)
- # off-topic (77)
- # pathom (1)
- # re-frame (33)
- # reagent (28)
- # reitit (1)
- # rewrite-clj (2)
- # shadow-cljs (195)
- # spacemacs (1)
- # sql (60)
- # tools-deps (13)
- # vim (18)
- # xtdb (46)
Hello, This is my first clojure or even slack question ever so please let me know if this is not the right channel or if I'm not asking the question the right way. So here is my problem. I'm making a checkers game to learn reframe and I made a subscription to show the pieces on the board. Here is a screenshot of my code The first way I wrote the subscribtion does the job just fine. However from the course of Eric Normand I understand that it is bad to call a subrscription within the let command and we should use de-duplication. This is what I tried to do with the second formulation on line 11. However for some strange reason the piece_dict variable contains nil and not the subscription [:piece row :col] I have two questions with respect to that: 1. What is wrong with my second formulation and why doesn't piece_dict contain the previous subscription 2. why is it that the first formulation is bad?
Welcome @U015631CK4M 👋 You might try asking over in #re-frame.
Has anybody run into the "SCRIPT1053: Const must be initialized" problem with Internet Explorer? My ClojureScript app stopped working on IE recently, and I'm not even sure where to start looking...
It might (and probably does), but I'm seeing this in a compiled app for the moment, so I have no idea.
I think at some point the CLJS compiler has started to emit the code like that, and IE doesn't support it.
that is incorrect. the CLJS compiler does not emit that code but the Closure Library has some code that uses it.
regular CLJS does not transpile during development I believe but it should be fine in release builds?
Well, I do use :advanced
compilation — and the problem appeared recently. I've been wondering if anybody else noticed. IE 11 is still an officially supported browser, unfortunately.
Would there be any serious implications to limiting to es3? Big performance loss, major regressions?
@U0511PZ1R Increased bundle size. Imo es5 should be "good enough" to cover ie11.
According to http://caniuse.com, es5 is supported in IE11. But it has a problem with const declarations in for loops.
@U0511PZ1R const is not a part of es5 specification. That's es6.
there are no vars so few var related thing exist at runtime - you can do some of these things via macros but you need to understand the implications - except for a small number of use cases I would avoid it
I'm working with goog.ui.Tooltip
. To change the tooltip's position, I think I need to set the "positioning strategy." In https://google.github.io/closure-library/api/goog.ui.Tooltip.html#getPositioningStrategy for getPositioningStrategy
, it says you can "Override in subclasses to customize the way repositioning is done." I'm not entirely sure how this should be done in cljs. I have tried the below snippet but it causes some goog assertion errors to get thrown which look like the result of some null or missing properties. I'm not sure if this is the correct way to do it & the assertion errors need to be fixed or if this is the wrong approach and using the correct approach would not result in failed assertions. Any ideas on how this can be done?
(js/Object.create
(.-prototype goog.ui.Tooltip)
#js{:getPositioningStrategy #js{:configurable true
:value (fn [_]
;; overriden method
)}})
@kenny how do you show the tooltip? you don't really need to subclass anything normally?
It shows itself by calling https://github.com/google/closure-library/blob/5359ebb8cd7882c3195db548edb660f987988568/closure/goog/ui/tooltip.js#L571 when the attached element is hovered/focused.
It eventually https://github.com/google/closure-library/blob/5359ebb8cd7882c3195db548edb660f987988568/closure/goog/ui/tooltip.js#L640 and will either pass opt_pos (an arg passed to the positionAndShow_ fn) otherwise default to this.getPositioningStrategy. If I walk the method calls back, there are two places that could pass the opt_pos arg that would get to positionAndShow_ (it gets passed down by a call to startShowTimer). One of https://github.com/google/closure-library/blob/5359ebb8cd7882c3195db548edb660f987988568/closure/goog/ui/tooltip.js#L705 does not pass opt_pos at all and https://github.com/google/closure-library/blob/5359ebb8cd7882c3195db548edb660f987988568/closure/goog/ui/tooltip.js#L766 passes it but implicitly calls getPositioningStrategy haha!
So, afaict, there is no way to customize the tooltip position via a setter on goog.ui.Tooltip. The docs imply this in the https://google.github.io/closure-library/api/goog.ui.Tooltip.html#getPositioningStrategy: "Return a Position instance for repositioning the tooltip. Override in subclasses to customize the way repositioning is done."
I can also get somewhat close with this:
(defn TT
[]
(this-as this
(prn "construct")
(js/Reflect.construct goog.ui.Tooltip #js [] TT)
this))
(set! (.-prototype TT)
(.-prototype goog.ui.Tooltip))
(doto (TT.)
(.setText text)
(.attach element-id))
I however, will get the same "Assertion failed: goog.dom.setTextContent expects a non-null value for node" error thrown.Oh wow, this appears to work!
(defn TT
[{::keys [position]}]
(this-as this
(prn "construct")
;(js/Reflect.construct goog.ui.Tooltip #js [] TT)
(goog.ui.Tooltip.call this)
(set! (.-ttPosition ^js this) position)
this))
(set! (.-prototype TT)
(js/Object.create (.-prototype goog.ui.Tooltip)
#js{:getPositioningStrategy #js{:configurable true
:value (fn [asd]
(this-as this (.-ttPosition ^js this)))}}))
(doto (TT. {::position (goog.positioning.AnchoredPosition.
(.getElementById js/document element-id)
corner)})
(.setText text)
(.setShowDelayMs show-delay-ms)
(.attach element-id))
is there a recommended way to pass an async/await async handler to javascript? for example, how would i reproduce this in cljs?
messaging().setBackgroundMessageHandler(async remoteMessage => {
console.log('Message handled in the background!', remoteMessage);
});
That function isn't doing anything with async/await. the async there is completely unneeded.
You can just pass a normal function.
In general, unless you pull in some library, async/await is just sugar for promises and you can deal with those using normal js interop in clojurescript.
Good point.