Skip to content

Make FilteredList's work more like computes #24

@akagomez

Description

@akagomez

Computes don't setup bindings on dependent properties until they're bound:

var firstName = can.compute('Chris');
var lastName = can.compute('Gomez'); 
var fullName = can.compute(function () {
  return firstName() + ' ' + lastName(); 
}); // Nothing is done
fullName.bind('change', function () {
  // Do something
}); // Binds to "change" events on `firstName` and `lastName` 

We should be able to do something similar with FilteredList's:

var source = new can.List(['a', 'b', 'c']); 
var filtered = source.dFilter(function (letter) {
  return letter === 'b';
}); // An empty FilteredList is returned

filtered.attr(0); // Iterates `source` until the first element that passes the predicate is found

filtered.bind('add', function () {
  // Do something
}); // Binds to "add", "remove" and creates computes for each element in `source`. 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions