Skip to content

Instantly share code, notes, and snippets.

@jstrimpel
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jstrimpel/45b5ae204feba3652358 to your computer and use it in GitHub Desktop.
Save jstrimpel/45b5ae204feba3652358 to your computer and use it in GitHub Desktop.
Lazo Widget Enhancements Design

Widget instances should have an event aggregator.

Triggering Events

Signature is eventName and data.

Listening for Events

Signature is eventName and callback that receives data from event trigger.

// el - the element to be used to create the widget instance
// name - the name to resolve to in the widget hash
// options
// - attributes - widget attributes
// - success - call after widget has been instantiated and life cycle is complete
// - error - call if there is an error during construction or life cycle
<LazoView||LazoWidget>.prototype.createWidget = function (el, name, options) {
// 1. el - update attributes, i.e., lazo-widget="name"
// 2. resolve name to class in widget hash or use Class
// if Class already exists throw error
// 3. Construct instance; pull attributes from options; follow widget life cycle
// 4. push instance to widget instances array
// 5. call options.success(this)
}

Widget should be composable. Widgets should resolve to properties in the <instance>.widgets just as they do in views.

  1. Construction
  2. Render if there are not any child nodes
  3. Parse rendered markup and look for child widgets. If found repeat steps 1 - 3 until none are found.

Widget afterRender and bind will happen from the top down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment