Skip to content

Instantly share code, notes, and snippets.

@mjvesa
Created April 8, 2016 11:14
Show Gist options
  • Save mjvesa/71665d27bd3f2c0f388293be04f0c361 to your computer and use it in GitHub Desktop.
Save mjvesa/71665d27bd3f2c0f388293be04f0c361 to your computer and use it in GitHub Desktop.
Example of the newer define-widget form for defining Vaadin widgets
;; Example of a custom Vaadin widget in Scheme using Spil (github.com/mjvesa/spil)
;;
;; define-widget is a macro which takes the code and distributes it between the client and server
;; client part is uploaded to the browser
;; call-server invokes a server-rpc from the client side
;; server-rpc defines a server-rpc
(define-widget (button text listener)
`((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