Skip to content

Instantly share code, notes, and snippets.

@kurogelee
Created May 17, 2014 04:15
Show Gist options
  • Save kurogelee/d4e29a56856cea298cb5 to your computer and use it in GitHub Desktop.
Save kurogelee/d4e29a56856cea298cb5 to your computer and use it in GitHub Desktop.
LightTable"を"プログラミングする初歩 ref: http://qiita.com/kurogelee/items/7d3ac7a3fecae3279e1b
(ns sample.core
(:require [lt.object :as o])
(:require-macros [lt.macros :as m]))
(o/object* ::my-template-name
:tags [:my-tag-name]
:some-nebulous-state [],
:other-state-like-thing {})
(m/behavior ::my-behavior-name
:triggers #{:my-trigger-name}
:reaction (fn [self & rest]
(prn (str "self:" self " and: " rest))))
(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")
{:+ {:my-tag-name [:sample.core/my-behavior-name]}}
{:+ {:my-tag-name [(:sample.core/my-behavior-name "xyzzy" "thud"]}}
(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