Last active
August 29, 2015 14:01
-
-
Save jemmons/2297e1d4688817a40e6b to your computer and use it in GitHub Desktop.
Getting Started Programming Light Table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns reverb.lighttable | |
(:require lt.object) | |
(:require-macros lt.macros)) | |
(lt.object/object* ::my-template-name :tags [:my-tag-name] :some-nebulous-state [], :other-state-like-thing {}) | |
(lt.object/->def ::my-template-name) | |
(lt.object/create ::my-template-name) | |
(lt.object/instances-by-type ::my-template-name) | |
(lt.macros/behavior ::my-behavior-name | |
:triggers #{:my-trigger-name} | |
:reaction (fn [self & rest] | |
(prn (str "self:" self " and: " rest)))) | |
(lt.object/->behavior ::my-behavior-name) | |
;; For illustrative purposes only. You should normally do this via `user.behaviors`. | |
(lt.object/add-behavior! (first (lt.object/by-tag :my-tag-name)) [::my-behavior-name]) | |
(lt.object/raise (first (lt.object/by-tag :my-tag-name)) :my-trigger-name "foo") | |
;; Note that in the above, we find our objects `by-tag`, but we can use anything that returns (an) object(s). For example `intances-by-type`, or even `by-id`. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment