Skip to content

Instantly share code, notes, and snippets.

@mjvesa
Last active August 30, 2015 18:17
Show Gist options
  • Save mjvesa/136c8b60075bc36a3ebc to your computer and use it in GitHub Desktop.
Save mjvesa/136c8b60075bc36a3ebc to your computer and use it in GitHub Desktop.
;; Example of a custom Vaadin widget in Scheme using Spil (github.com/mjvesa/spil)
;;
;; The widget macro is wrapped in another macro to set the button text and callback listener
;; client part is uploaded to the browser
;; call-server invokes a server-rpc from the client side
;; server-rpc defines a server-rpc
(define-macro (button text listener)
`(widget
(client
(let ((button (element-new '(button ,text))))
(append-to-root button)
(js-set! button "onclick" (js-closure (lambda () (call-server 'click '()))))))
(server-rpc (click ev)
(,listener))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment