Since squint v0.1.15
is it possible to define JavaScript classes, using the
defclass
syntax. Here is an example that should show most of what is
possible. The syntax is inspired by
shadow-cljs.
(ns my-class
(:require [squint.core :refer [defclass]]))
(defclass class-1
(field -x)
(field -y :dude) ;; default
(constructor [this x] (set! -x x))
Object
(get-name-separator [_] (str "-" -x)))
(defclass Class2
(extends class-1)
(field -y 1)
(constructor [_ x y]
(super (+ x y -y)))
Object
(dude [_]
(str -y (super.get-name-separator)))
(toString [this] (str "<<<<" (.dude this) ">>>>") ))
(def c (new Class2 1 2))
See squint-lit-example on how to use squint together with lit. Or check out web-components-squint for a more elaborate example.