-
Notifications
You must be signed in to change notification settings - Fork 2
roles
Roles are simple string values attached to the prototype of most Class Objects in the sudo.js library. This property is referenced in the constructor function of View types as a means to delay calling this.init until as late as possible.
For example, consider the fact that DataView inherits from View and that a subclass of DataView may contain an init method. Without the functionality provided by "role references" the init method of that subclass would be called too soon, before the object was fully formed. Why? DataView calls its super constructor, sudo.View, before finishing its own construction step. When executing, the View constructor sees the role property of the subclass is not 'view' and skips the call to 'init', returning control to the Dataview constructor where 'init' will be called suitably late.
###Delegates and Roles
See the Delegate section of the base docs for an intro to delegates.
Any Class object inheriting from Base has Delegate functionality. While a class may have multiple Delegates, it may only have a single active Delegate per 'role' type. If you were to add two delegates with a role of 'foo' for example only the first would be found when calling this.delegate or this.getDelegate.