Add example to the overlay function.

This commit is contained in:
Irakli Gozalishvili 2012-10-28 21:08:45 -07:00
Родитель cace2bae08
Коммит a21b86679f
1 изменённых файлов: 20 добавлений и 0 удалений

Просмотреть файл

@ -22,6 +22,26 @@ function overlay(mapping) {
components could use them as regular state attributes. Also note that
resulting stream will only contain changes to the computed properties
if they actually changed.
## Example
var foo = overlay({
count: function(previous, current) {
var items = current.items
var ids = Object.keys(items)
var completed = ids.map(function(id) {
return items[id]
}).filter(function(item) {
return item.completed
}).length
return {
all: items.count,
completed: completed,
pending: count - completed
}
}
})
**/
// Cache keys of the mapping in an array to avoid call overhead on each