Skip to content

Instantly share code, notes, and snippets.

@Raynos
Last active December 11, 2015 03: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 Raynos/49be1da3f12823a52b70 to your computer and use it in GitHub Desktop.
Save Raynos/49be1da3f12823a52b70 to your computer and use it in GitHub Desktop.
/*
dataRepresentation is some representation of the data over time.
Either a stream, EventEmitter, Reducible or (any old mutable data + Object.observe)
*/
function SomeWidget(dataRepresentation) {
// A widget can use whatever templating scheme it likes
var elements = invokeTemplate()
// A widget data binds the data representation onto it's DOM by some
// kind of binding schema.
oneWayDataBind(elements, dataRepresentation, someDataBindSchema)
// A widget grabs all relevant user input out of the DOM thing
// And transform it into a result.
var result = transform(userInputFrom(elements), function () {
/* transform DOM input into some kind of useful DOM agnostic data structure */
})
// A widget must expose both the DOMElement and the result (somehow)
result.view = elements.root
// A widget's result is some representation of data based on user input over time
// So either stream, EventEmitter, Reducible or (mutable object + Object.observe)
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment