From 59dbee8f284e31fc3f00bcbb54c6c877185837da Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Tue, 28 Apr 2015 17:06:37 +0200 Subject: [PATCH] Minor doc about views. --- packages/xo-collection/README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/packages/xo-collection/README.md b/packages/xo-collection/README.md index f6367957c..cb905c115 100644 --- a/packages/xo-collection/README.md +++ b/packages/xo-collection/README.md @@ -179,6 +179,25 @@ for (let value of col.values()) { } ``` +### Views + +```javascript +const View = require('xo-collection/view') +``` + +> A view is a read-only collection which contains only the items of a +> parent collection which satisfy a predicate. +> +> It is updated at most once per turn of the event loop and therefore +> can be briefly invalid. + +```javascript +const myView = new View(parentCollection, function predicate (value, key) { + // This function should return a boolean indicating whether the + // current item should be in this view. +}) +``` + ## Development ### Installing dependencies