widget.esl 649 B

1234567891011121314151617
  1. (lambda widget (closure)
  2. (var Widget (lambda (options)
  3. (if (! (instanceof this Widget)) (return (new Widget options)))
  4. (= this.options options)))
  5. (= Widget.prototype.type "Widget")
  6. (= Widget.prototype.init (lambda ()
  7. (= this.state (closure this.options))
  8. (return this.state.element)))
  9. (= Widget.prototype.update (lambda (prev)
  10. (= this.state prev.state)
  11. (return (?: this.state.update
  12. (this.state.update.apply this arguments) null))))
  13. (= Widget.prototype.destroy (lambda ()
  14. (if this.state.destroy (this.state.destroy.apply this arguments))))
  15. (return (lambda (options)
  16. (return (new Widget options)))))