зеркало из https://github.com/mozilla/reflex.git
Add example to the overlay function.
This commit is contained in:
Родитель
cace2bae08
Коммит
a21b86679f
20
overlay.js
20
overlay.js
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче