algebra
can-set
set algebra used for list comparison, instance identification and membership
calculations. A way for the can-connect
behaviors to understand what the properties of a request mean and act
on them.
Algebra(compares)
A set algebra that is used to perform calculations using set definition objects passed to getListData and getList. Needed to enable caching, request combining, real-time and other behaviors. By default no algebra is provided.
An example of the types of calculations behaviors will make using the algebra:
var algebra = new set.Algebra(
set.props.id('_uid'),
set.props.rangeInclusive("first","last")
);
var todoConnection = connect([...behaviors...],{
algebra: algebra
});
todoConnection.algebra.id({_uid: 5, ...}); //-> 5
todoConnection.id({_uid: 5, ...}); //-> 5
todoConnection.algebra.intersection({first: 0, last: 10}, {first:5, last:20}); //-> {first:5, last:10}
todoConnection.algebra.has({first: 0, last:10}, {_uid:5, ...}); //-> true
todoConnection.algebra.has({first: 0, last:10}, {_uid:11, ...}); //-> false