(use-modules (reactive) (hoot ffi)) (define-foreign get-element-by-id "document" "getElementById" (ref string) -> (ref null extern)) (define-foreign element-inner-text "element" "innerText" (ref null extern) -> (ref string)) (define-foreign set-element-inner-text! "element" "setInnerText" (ref null extern) (ref string) -> none) (define-foreign add-event-listener! "element" "addEventListener" (ref null extern) (ref string) (ref null extern) -> none) (define cell-a (make-cell 42)) (format #t "~s\n" (! cell-a)) (define deriv-a (~ (format #f "value is: ~s" (! cell-a)))) (format #t "~a\n" (! deriv-a)) (! cell-a 56) (format #t "~a\n" (! deriv-a)) (define counter-cell (make-cell 0)) (define button-elem (get-element-by-id "button")) (add-event-listener! button-elem "click" (procedure->external (lambda (e) (! counter-cell (1+ (! counter-cell)))))) (define counter-elem (get-element-by-id "counter")) (define counter-deriv (~ (set-element-inner-text! counter-elem (number->string (! counter-cell))) #f))