Created
May 17, 2014 04:15
-
-
Save kurogelee/d4e29a56856cea298cb5 to your computer and use it in GitHub Desktop.
LightTable"を"プログラミングする初歩 ref: http://qiita.com/kurogelee/items/7d3ac7a3fecae3279e1b
This file contains hidden or 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 sample.core | |
(:require [lt.object :as o]) | |
(:require-macros [lt.macros :as m])) |
This file contains hidden or 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
(o/object* ::my-template-name | |
:tags [:my-tag-name] | |
:some-nebulous-state [], | |
:other-state-like-thing {}) |
This file contains hidden or 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
(m/behavior ::my-behavior-name | |
:triggers #{:my-trigger-name} | |
:reaction (fn [self & rest] | |
(prn (str "self:" self " and: " rest)))) |
This file contains hidden or 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
(o/add-behavior! | |
(first (o/by-tag :my-tag-name)) | |
[::my-behavior-name]) | |
(o/raise (first (o/by-tag :my-tag-name)) | |
:my-trigger-name) | |
(o/raise (first (o/by-tag :my-tag-name)) | |
:my-trigger-name :a "b") |
This file contains hidden or 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
{:+ {:my-tag-name [:sample.core/my-behavior-name]}} |
This file contains hidden or 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
{:+ {:my-tag-name [(:sample.core/my-behavior-name "xyzzy" "thud"]}} |
This file contains hidden or 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
(defn make-object* [name & r] | |
(let [obj (merge {:behaviors #{} :tags #{} :triggers [] :listeners {} ::type name :children {}} | |
(apply hash-map r))] | |
obj)) | |
(defn object* [name & r] | |
(-> (apply make-object* name r) | |
(store-object*) | |
(handle-redef))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment