Generic Collections 0.75

Generic typed collections for Mootools.



Details

Author
Nic Bell
Current version
0.75
GitHub
nicbell/MooCollections
Downloads
4100
Category
Native
Tags
Report
GitHub Issues

Releases


How to use

All we need to do is create a new 'Collection' of a specific type. Great when working with different kinds of data. Use Generics.Collection.add(item) to add and use Generics.Collection.remove(item) to remove.

JS:

var Pig = new Class();
var Piglet = new Class({ Extends: Pig });
var Cow = new Class();

var pigs = new Generics.Collection(Pig); //pass class

pigs.add(new Pig());
pigs.add(new Piglet());
pigs.add(1); //Type exception: item is not an object.
pigs.add(new Cow()); //Type exception: item of incorrect type.

alert(pigs.length); //2

Discuss

A note on comments here: These comments are moderated. No comments will show up until they are approved. Comments that are not productive (i.e. inflammatory, rude, etc) will not be approved.

Found a bug in this plugin? Please report it this repository's Github Issues.

blog comments powered by Disqus