nanomap
Functionally map data into stateful nanocomponents.
Usage
var Nanomap = var YoutubeComponent = var TwitterComponent = var OEmbedComponent = var simpleMapper = opts TwitterComponent// ORvar complexMapper = opts 'video': YoutubeComponent 'tweet': TwitterComponent ... default: OEmbedComponent id: 'foo123' opts: color: 'blue' arguments: an: 'arg' // Non-array types passed in as the first argument // Array of rendered DOM nodes from homogeneous components id: 'foo123' type: 'tweet' arguments: 'tweet-url' // component.render.apply(component, arguments) // Array of rendered DOM nodes from a heterogeneous set of components
Installation
$ npm install nanomap
API
Nanomap = require('nanomap
)
Import Nanomap
component class.
mapper = new Nanomap([opts], Component)
mapper = Nanomap([opts], { type: Component, [default: Component]})
Create a new mapper instance that will render data into component instances.
opts
include:
gc: true // clean up unused instances when mapped over
See examples for more details.