Great things have small beginnings. Again.
Robo is a frontend Coffeescript framework that is effectively a combination of micro-libraries, opinionated classes and patterns, and prescriptive project structure and build steps.
Robo has be re-imagined, re-started, and re-written several times. This time, it's in Coffeescript... so it's back to scratch one.
Events are the low-level construct that power Robo's dynamic features. The
eventing functions are found on the event/WithEvents
class and can be mixed
into any class.
It features both the on
/off
style of setting up callbacks for when an event
is triggered, and listenTo
/stopListening
to invert the responsibility of
keeping track of the events.
class Eventer extends Base
@uses WithEvents # mixin pattern via robo/util/Base
constructor: ->
@on alert: (m) -> console.log "alert: #{m}"
a = new Eventer
a.trigger 'alert', 'some message'
Output:
alert: some message
Full documentation for the WithEvents
mixin
Most significant parts of Robo are built around the idea of observable objects. This lets us build dynamic applications that react to data changes and have rich behavior, all handled in a standard way.
Robo comes stock with several observable types: ObservableObject
,
ObservableList
, ObservableDictionary
, ObservableSet
.
class Person extends ObservableObject
@observable firstName: 'John'
@observable lastName: 'Doe'
@observable fullName: -> "#{@firstName} #{@lastName}"
person = new Person
person.onPropertyChange
fullName: -> console.log 'full name changed'
firstName: -> console.log 'first name changed'
person.firstName = 'Bob'
Output:
first name changed
full name changed
Full documentation for Observable
mixin
Full documentation for the Binding
class
Testing requires node/npm and grunt-cli to be installed on your system.
To install all the dev dependencies and run the test target:
npm install
grunt test
Copyright 2013 Brandon Valosek
Robo is released under the MIT license.