Fork me on GitHub
#unrepl
<
2017-04-10
>
dominicm17:04:57

@cgrand aset is for arrays. You want goog.object, aset works by coincidence.

cgrand17:04:50

@dominicm source that it is frowned upon/not guaranteed to keep working?

dominicm17:04:46

https://cljs.github.io/api/cljs.core/aset these docs. Also conversations with @anmonteiro (who can probably point at the correct source)

pesterhazy17:04:39

yeah dnolen doesn't like aget/aset used for JS objects

thheller17:04:56

@cgrand (:require [goog.object :as gobj]) (gobj/set obj "foo" 1)

thheller17:04:07

it is more about the closure compiler really

thheller17:04:28

they don't like obj["foo"] = 1

pesterhazy17:04:26

@thheller using brackets makes the closure compiler not minify the properties, but not minifying is often exactly what you want

thheller17:04:07

goog.object is inlined to the above as well and won't be renamed

pesterhazy17:04:08

I think the point is more that aget/aset exists in clojure and operates on arrays, and the fact that it works for objects is an implementation detail you don't want to rely on

thheller17:04:42

goog.object just interacts better with the closure type system

pesterhazy17:04:56

I agree goog.object/set is the way to go

pesterhazy17:04:23

I didn't know that there's an interaction with the closure type system

pesterhazy17:04:52

fun fact: goog.object is automatically required so you should be able to use it without the require clause

thheller18:04:50

I hate using the long name ๐Ÿ˜‰ ... also always require everything you use ... will only lead to issues if you dont

pesterhazy18:04:53

yes I guess you're right

pesterhazy18:04:19

oh I wish that gobj/get and gobj/set were part of cljs.core

pesterhazy18:04:33

but that ship has sailed ๐Ÿ™‚

cgrand18:04:03

Thanks all

dominicm19:04:05

Sorry. Didn't mean to turn this into a big conversation ๐Ÿ˜› That code looks really useful.