Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added can/map/list documentation, fixed typos in lazymap docs #1432

Merged
merged 1 commit into from Feb 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion map/lazy/lazy.md
Expand Up @@ -45,4 +45,4 @@ lazyPerson.attr('chores') // Now chores is a can.List

## See Also

For information on manipulating attributes, see [can.Map.prototype.attr attr]. To see what events are fired on property changes and how to listen for those events see [can.Map.prototype.bind bind].
For information on manipulating attributes, see [can.Map.prototype.attr attr]. To see what events are fired on property changes and how to listen for those events see [can.Map.prototype.bind bind].
54 changes: 54 additions & 0 deletions map/list/list.md
@@ -0,0 +1,54 @@
@page can.Map.List
@parent can.Map.plugins
@plugin can/map/list
@test can/map/list/test.html

@deprecated {2.1} This plugin is pending review and its API has not been finalized. Including this plugin will overwrite [can.List.prototype.filter] (which is faster but doesn't provide live-updating). The new `filter` and `map` methods also have a slightly different API, including the _element_, _index_, and _list_ as arguments (instead of only _element_ and _list_).

@description

The `can.Map.List` plugin adds support for live-updating mapped and filtered observable lists.



@signature `list.filter(callback)`

Generates a new filtered list that live-updates itself to contain the filtered items of the original list.

@codestart
var list = new can.List([
{ name: 'Justin' },
{ name: 'Brian' },
{ name: 'Austin' },
{ name: 'Mihael' }])

// Returns a filtered list that only matches names containing an "n"
var filtered = list.filter(function(element, index, list) {
return item.attr("name").match(/n/i);
});
@codeend

@param {function(element,index,list)} callback A filtering function that will determine whether an element is filtered or not.
@return {can.List} A live-updating filtered list.


@signature `list.map(callback)`

Generates a new mapped list that live-updates itself to contain the mapped items of the original list.

@codestart
var list = new can.List([
{ name: 'Justin' },
{ name: 'Brian' },
{ name: 'Austin' },
{ name: 'Mihael' }])

// Returns a mapped list that returns the element names.
var filtered = list.filter(function(element, index, list) {
return item.attr("name");
});
@codeend


@param {function(element,index,list)} callback A mapping function that will determine each element's mapped value.
@return {can.List} A live-updating mapped list.