Fork me on GitHub

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.


Thanks I didn't know there was this channel


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...


Does it point to some code that looks like for (const i = ...)?


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?


Ah, I see. Thanks!


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.


is this shadow-cljs?


if not the setting is :language-out :es3 in your build compiler options


I use lein cljsbuild. Will try that.


Would there be any serious implications to limiting to es3? Big performance loss, major regressions?

Karol Wójcik13:06:56

@U0511PZ1R Increased bundle size. Imo es5 should be "good enough" to cover ie11.


According to, es5 is supported in IE11. But it has a problem with const declarations in for loops.

Karol Wójcik13:06:47

@U0511PZ1R const is not a part of es5 specification. That's es6.


Is there a var-get alternative in clojurescript?


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


thank you


I'm working with goog.ui.Tooltip. To change the tooltip's position, I think I need to set the "positioning strategy." In 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?

  (.-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 eventually 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 does not pass opt_pos at all and 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 "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)

(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)
    ( this)
    (set! (.-ttPosition ^js this) position)

(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)
  (.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);

Jimmy Miller21:06:54

That function isn't doing anything with async/await. the async there is completely unneeded.

Jimmy Miller21:06:10

You can just pass a normal function.

Jimmy Miller21:06:44

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.


thats not entirely true here


it is an async function so it is a function that always returns a promise


which may or may not be relevant


I don't know about that part


but yeah basically if the function demands it just return a promise


if its fine with getting nil use a simple function


thanks guys