Remove redundant features: ref sugar, suspense, transitions
- ref/ref-get/ref-set! functions removed (just dict wrappers — use dict primitives directly). The :ref attribute stays in adapter-dom.sx. - Suspense form removed (if/when + deref on resource signals covers it) - Transition function removed (fine-grained signals already avoid jank) - Kept: error-boundary, resource, portal, :ref attribute Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -187,7 +187,7 @@
|
||||
(bind-input el attr-val)
|
||||
;; ref: set ref.current to this element
|
||||
(= attr-name "ref")
|
||||
(ref-set! attr-val el)
|
||||
(dict-set! attr-val "current" el)
|
||||
;; Boolean attr
|
||||
(contains? BOOLEAN_ATTRS attr-name)
|
||||
(when attr-val (dom-set-attr el attr-name ""))
|
||||
@@ -310,7 +310,7 @@
|
||||
(list "if" "when" "cond" "case" "let" "let*" "begin" "do"
|
||||
"define" "defcomp" "defisland" "defmacro" "defstyle" "defhandler"
|
||||
"map" "map-indexed" "filter" "for-each" "portal"
|
||||
"error-boundary" "suspense"))
|
||||
"error-boundary"))
|
||||
|
||||
(define render-dom-form?
|
||||
(fn (name)
|
||||
@@ -435,10 +435,6 @@
|
||||
(= name "error-boundary")
|
||||
(render-dom-error-boundary args env ns)
|
||||
|
||||
;; suspense — show fallback while resource is loading
|
||||
(= name "suspense")
|
||||
(render-dom-suspense args env ns)
|
||||
|
||||
;; for-each (render variant)
|
||||
(= name "for-each")
|
||||
(let ((f (trampoline (eval-expr (nth expr 1) env)))
|
||||
@@ -828,66 +824,6 @@
|
||||
container))))
|
||||
|
||||
|
||||
;; --------------------------------------------------------------------------
|
||||
;; render-dom-suspense — show fallback while resource is loading
|
||||
;; --------------------------------------------------------------------------
|
||||
;;
|
||||
;; (suspense fallback-expr body...)
|
||||
;;
|
||||
;; Renders fallback-expr initially. When used with a resource signal,
|
||||
;; an effect watches the resource state and swaps in the body content
|
||||
;; once loading is complete. If the resource errors, renders the error.
|
||||
;;
|
||||
;; The simplest pattern: wrap a resource deref in suspense.
|
||||
;;
|
||||
;; (suspense
|
||||
;; (div "Loading...")
|
||||
;; (let ((data (get (deref user-resource) "data")))
|
||||
;; (div (get data "name"))))
|
||||
|
||||
(define render-dom-suspense
|
||||
(fn (args env ns)
|
||||
(let ((fallback-expr (first args))
|
||||
(body-exprs (rest args))
|
||||
(container (dom-create-element "div" nil)))
|
||||
(dom-set-attr container "data-sx-suspense" "true")
|
||||
;; Render fallback immediately
|
||||
(dom-append container (render-to-dom fallback-expr env ns))
|
||||
;; Try to render body — if it works, replace fallback
|
||||
;; The body typically derefs a resource signal, which triggers
|
||||
;; an effect that re-renders when the resource resolves
|
||||
(let ((body-disposers (list)))
|
||||
(effect (fn ()
|
||||
;; Dispose previous body renders
|
||||
(for-each (fn (d) (d)) body-disposers)
|
||||
(set! body-disposers (list))
|
||||
;; Try rendering the body
|
||||
(try-catch
|
||||
(fn ()
|
||||
(let ((frag (create-fragment)))
|
||||
(with-island-scope
|
||||
(fn (disposable)
|
||||
(append! body-disposers disposable)
|
||||
(register-in-scope disposable))
|
||||
(fn ()
|
||||
(for-each
|
||||
(fn (child)
|
||||
(dom-append frag (render-to-dom child env ns)))
|
||||
body-exprs)))
|
||||
;; Success — replace container content with body
|
||||
(dom-set-prop container "innerHTML" "")
|
||||
(dom-append container frag)))
|
||||
(fn (err)
|
||||
;; Body threw — keep showing fallback (or show error)
|
||||
nil))))
|
||||
;; Register cleanup
|
||||
(register-in-scope
|
||||
(fn ()
|
||||
(for-each (fn (d) (d)) body-disposers)
|
||||
(set! body-disposers (list)))))
|
||||
container)))
|
||||
|
||||
|
||||
;; --------------------------------------------------------------------------
|
||||
;; Platform interface — DOM adapter
|
||||
;; --------------------------------------------------------------------------
|
||||
@@ -944,7 +880,6 @@
|
||||
;; From signals.sx:
|
||||
;; signal, deref, reset!, swap!, computed, effect, batch
|
||||
;; signal?, with-island-scope, register-in-scope
|
||||
;; ref, ref-get, ref-set!
|
||||
;;
|
||||
;; Pure primitives used:
|
||||
;; keys, get, str
|
||||
|
||||
Reference in New Issue
Block a user