Clojurians
#cljs-dev
<
2017-05-11
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

john17:05:41

It appears as though the docs for set-validator!are inaccurate. https://crossclj.info/ns/org.clojure/clojurescript/latest/cljs.core.cljs.html#_set-validator%21

If the current state
  is not acceptable to the new validator, an Error will be thrown and the
  validator will not be changed.

john17:05:41

I'm working on a custom ref type right now, so I may end up with something fitting for a patch.

john17:05:31

dev:user.ex=> (def s (atom 1))
#'user.ex/s
dev:user.ex=> 
dev:user.ex=> (set-validator! s even?)
#object[cljs$core$even_QMARK_ "function cljs$core$even_QMARK_(n){
if(cljs.core.integer_QMARK_(n)){
return ((n & (1)) === (0));
} else {
throw (new Error([cljs.core.str.cljs$core$IFn$_invoke$arity$1("Argument must be an integer: "),cljs.core.str.cljs$core$IFn$_invoke$arity$1(n)].join('')));
}
}"]
No Error thrown.

john17:05:45

But cross-clj sees only one usage of set-validator! out there, so it's probably not a big deal.

john19:05:05

@mfikes Thanks!