LightTable Api Documentation

Version: 0.8.1

lt.object

Define core of BOT architecture and provide fns for manipulating objects,
behaviors and tags

*behavior-meta*

dynamic

Metadata of current behavior set during raise and raise-reduce

->content

(->content obj)
Return DOM content associated with object

->id

(->id obj)
Return id of given object

add-behavior!

(add-behavior! obj behavior)
Add behavior to object and update its listeners

add-tags

(add-tags obj ts)
Add tags to given object and updates effected behaviors and listeners.
::tags-added trigger is raised on object after update

assoc-in!

(assoc-in! obj k v)
Update object with assoc-in for given key and value

by-id

(by-id id)
Find object by its unique numerical id

by-tag

(by-tag tag)
Find objects that have given tag

call-behavior-reaction

(call-behavior-reaction id & args)
For a given behavior keyword id, call its :reaction fn with given args

create

(create obj-name & args)
Create object given keyword name of object template or an object template
and key-value pairs. See object* for special keys.
During object creation the following happens to object in order:

* :init fn is called with given args
* :object.instant trigger is raised
* :init trigger is raised

destroy!

(destroy! obj)
Destroy object by calling its :destroy trigger, removing it from
cache and removing associated DOM content

has-tag?

(has-tag? obj tag)
Return truthy if object has tag

instances-by-type

(instances-by-type type)
Return all objects for given type (template name)

merge!

(merge! obj m)
Merge map into object

object*

(object* name & r)
Create object template (type) given keyword name and key-value pairs.
These pairs serve as default attributes for an object. Following keys
have special meaning:

* :behaviors - Set of object's behaviors
* :tags - Set of object's tags
* :triggers - Set of object's triggers
* :init - Init fn called when object is created. Fn's return value
          is hiccup html content and saved to :content
* :listeners (internal) - Map of triggers to vectors of behaviors

raise

(raise obj k & args)
Invoke object's behavior fns for given trigger. Args are passed to behavior fns

raise-reduce

(raise-reduce obj k start & args)
Reduce over invoked object's behavior fns for given trigger. Start
is initial value for reduce and any args are passed to behavior fn

rem-behavior!

(rem-behavior! obj behavior)
Remove behavior from object and update its listeners

remove-tags

(remove-tags obj ts)
Remove tags from given object and updates effected behaviors and listeners.
::tags-removed trigger is raised on object after update

safe-report-error

(safe-report-error e)
TODO: Add docstring

tag-behaviors

(tag-behaviors tag behs)
Associate behaviors to given tag and refresh objects with given tag

update!

(update! obj & r)
Update object with update-in with [:key], fn and args