lt.object
Define core of BOT architecture and provide fns for manipulating objects,
behaviors and tags
->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
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)
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
safe-report-error
(safe-report-error e)
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