Skip to content

Instantly share code, notes, and snippets.

@cjbell
Last active December 11, 2015 13:09
Show Gist options
  • Save cjbell/4605615 to your computer and use it in GitHub Desktop.
Save cjbell/4605615 to your computer and use it in GitHub Desktop.
Big Bird Controller example #1
var ControllerExample = BigBird.Controller.extend({
// This function gets $.proxy(ied) for you automatically.
// That means you can call it without it losing lexical scope
proxied: ["myFunction"],
// We can subscribe to new events through the subscriptions
// shorthand. If $.publish("/updateVariable") gets called, then
// the myFunction method is invoked.
subscriptions: {
"/updateVariable", "myFunction"
},
myVariable: true,
// Intialize gets called on instantiation of the object
initialize: function() {
this.myFunction();
},
myFunction: function() {
this.myVariable = false;
}
});
// We can instantiate a new ControllerExample like so
// You can update set vraibles during this process too.
var ControllerInstance = new ControllerExample({ myVariable: false });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment