Fork me on GitHub

I was wondering if it was nested scrolls. It is not uncommon to have an external holder that fits the viewport so that the sidebar is fixed and the main content scrolls. Perhaps that’s it? I am not familiar with how that event bubbles.


has anyone had to format/compact numbers in cljs such that 43,000,000,000 becomes 43B? I know goog.i18n.NumberFormat is capable of this but I'm having trouble working out how exactly to make it work. Is this functionality in cljs.pprint/cl-format?


nvm got it

(:import (goog.i18n NumberFormat)
           (goog.i18n.NumberFormat Format))
(def formatter (NumberFormat. Format/COMPACT_SHORT))
(.format formatter 43000000000)
;;=> 43B


anyone know if cl-format supports this?


It does a lot (I hear it is Turing complete) but not that. You can roll your own, tho:

(defn pic9A [n]
  (let [scale (Math/floor (/ (Math/log10 n) 3))]
      nil "~d~v[~;K~;M~;B~;T~;G~]"
      (/ n (Math/pow 10 (* scale 3)))

👍 4

cool, thanks!


Lightly tested, and be careful, that is a capital A in the name as a hat-tip to Cobol.


Hi, i am working on adding inline doc search in my self-hosted clojurescript environment. using (meta (var map)) or (meta #'map) works great and gives me

{:ns cljs.core,
 :name map,
 :file "cljs/core.cljs",
 :end-column 10,
 {:variadic true,
  :max-fixed-arity 4,
  :method-params ([f] [f coll] [f c1 c2] [f c1 c2 c3]),
  :arglists ([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]),
  :arglists-meta (nil nil nil nil nil)},
 :column 1,
 :line 4654,
 :end-line 4654,
 :arglists ([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]),
 "Returns a lazy sequence consisting of the result of applying f to\n  the set of first items of each coll, followed by applying f to the\n  set of second items in each coll, until any one of the colls is\n  exhausted.  Any remaining items in other colls are ignored. Function\n  f should accept number-of-colls arguments. Returns a transducer when\n  no collection is provided.",
 :test nil}
however i want to pass the var name as a string, and doing (meta (var (symbol "cljs.core" "map"))) and is not working. What piece am i missing/getting wrong?


(meta (resolve (symbol "clojure.core" "map"))) ?

👍 4

@fj.abanses in CLJS this data is only available via the analyzer API. see cljs.analyzer.api

👍 4

if you are in self-hosted you should have access to the compiler env. there you could (get-in @compiler-env [:cljs.analyzer/namespaces 'cljs.core :defs 'map :meta])


thanks! @thheller giving it a try.


thanks @iperdomo, trying this also.


got it working. thanks for the help!! (get-in @cljs.env/*compiler* [:cljs.analyzer/namespaces 'cljs.core :defs (symbol "map") :meta])


I'm having some problems converting js to cljs code. I know I could use something like (def ig-obj (js/ig.module.requires.defines)) to get to a nested scope, but I have problems adding the options:

MyGame = ig.Game.extend({
	font: new ig.Font( 'media/04b03.font.png' ),
	init: function() {
	update: function() {
	draw: function() {
		var x = ig.system.width/2,
			y = ig.system.height/2;
		this.font.draw( 'It Works!', x, y, ig.Font.ALIGN.CENTER );


How would I go about adding the parameters to the nested scope?


You will actually probably want to use a threading macro here


Something like:

(-> js/ig
      (.module "game.main")
      (.requires "" "impact.font")
      (.defines my-defines-function))


As for 'nested scope' def (if I understand what you mean correctly) doesn't nest


You'll want to look at using let to define local variables


Hey all, does anyone have an example project of a pure clojurescript ui library, or just a library, which uses deps + clj cli tool? I am particularly interested in seeing how they run the production build...but in general, would just love to see some examples. Thanks!


Asking for Debug help: We have a pretty basic reagent app. It works for everyone else, but on my machine with a fresh git clone and using same DB as everyone, it fails. Fails both with figwheel and cljsbuild/run. No problems with java clojure, other cljs apps work fine. Same version of java, and I was previously a version behind them with lein but I get same behavior after upgrading to 2.8.1. I get a The map literal starting with :AWS contains 3 form(s). Map literals must contain an even number of forms. uncaught exception in cljs. (:AWS is a key loaded from a DB, not in source) Outside of throwing the laptop in the dumpster, I'm past my cljs knowledge on next steps to debug this, as no one else can repro this, and seems independent of the code itself.

Mario C.22:07:11

Ive gotten one of those before when I misplace my {}


It's a fresh git clone with same code as 5 others who don't see any errors. Also I think the error is coming from a reader attached to a core.async channel, as that literal does not actually appear in the code but rather as a response coming from the backend


If you are using the reader to parse the backend (bad idea imo) that would explain how it is different for you: somehow your login info is causing a different response from the server. You need to find where that’s happening, and put a try catch around that piece of the code so that you can dump the response from the server.


Thanks. There is no login info, the steps are literally:

git clone
lein figwheel
load page
get error
the same on each computer, only mine fails. Same network, connecting to same DB(verified as working), etc. I posted the stack trace elsewhere, but it's extremely opaque as they are all core fns.


I can go the route of adding in a ton of debug code every few calls, my focus thus far has been why would it work on 5 other machines and not mine, despite having nearly identical environments.


This is why I don’t like core async :)


i haven’t needed core async for anything since using reframe


side effects and async flows are handled so nicely that i don’t bother with the (mental) overhead of core.async


@U0W0JDY4C that’s interesting. that’s possibly the strongest argument for re-frame i’ve heard. though i worry that it turns everything into state machine programming


it does… but is that so bad? especially when dealing with UIs, nearly everything non-trivial could be improved with a fsm. also, i know @U051MTYAB is hammocking about ways to improve reframes FSM-like characteristics


I mean, all things being equal, it is nice to have the flow of data and networks calls laid out in a linear fashion, rather than trying to trace a sequence of events


i understand that the tooling helps and there are big gains from simplifying the steps


maybe it is a net improvement


maybe it’s just preferred flavors. i find that tracing discrete possibilities into completely isolated fns that are “somewhere else” is easier than trying to look at a big ol’ nested if block and/or some sort of loop/recur channel with branching conditionals


It’s complaining of a map literal rather than a map. Is source code for the map being generated as a clojurescript fragment (or edn) and then loaded?


The frontend does load some end from the backend. but it's all in the same project, connected to same db as others, and only breaks on my machine. The stack trace is very unhelpful:

"Error: The map literal starting with :AWS contains 3 form(s). Map literals must contain an even number of forms.
    at new cljs$core$ExceptionInfo ()
    at Function.cljs.core.ex_info.cljs$core$IFn$_invoke$arity$3 ()
    at Function.cljs.core.ex_info.cljs$core$IFn$_invoke$arity$2 ()
    at cljs$core$ex_info ()
    at$core$IFn$_invoke$arity$variadic ()
    at cljs$tools$reader$impl$errors$throw_ex ()
    at$core$IFn$_invoke$arity$variadic ()
    at cljs$tools$reader$impl$errors$reader_error ()
    at cljs$tools$reader$impl$errors$throw_odd_map ()
    at cljs$tools$reader$edn$read_map ()"


That actually answered one of my questions. Some EDN was generated, only the EDN was faulty and it can’t be parsed. So the trick is to find where it was created. Is it create dynamically and read in as a string? Is a file generated, and the file is read in? To start with, you’ll want to track down how the DB is read to get this info? What happens with that info once it’s read? Where does it go? Where is the code that reads the reader? Is it calling, or


finding where it’s read may give you hints as to where it was generated


Oh check the main forum, I found it was a deprecated cookie that we aren't reading in user code, but gets read by reagent


Somehow I got a corrupted cookie on my browser only. clearing it fixed. Oddly we aren't using cookies in our code anymore so didn't even think to clear cookies


Well done tracking it down!


my first thought (with extremely limited knowledge of what you have) is that the code doing that reading is not handling some condition that it’s running into


and only generates 3 elements, instead of the 4 it expected


@eriktjacobsen print the string before it is read


whups my bad everyone, false alarm. We had a deprecated reagent cookie that somehow got set with bad data on my browser. Clearing cookies was a critical step I failed to check, since we are no longer even using the cookies in our code. Apparently they are read at a lower level and caused a edn / reader failure outside of our user code. Thanks for the help everyone. (good reminder: always clear cookies)