new List(options)
A bindable Array wrapper that can be used when you don't require
web service connectivity.
Plain objects will automatically be converted into an instance of
the specified `itemClass` when added to a List, and the appropriate
events dispatched if the items it contains are changed or updated.
This class implements the Web Storage API.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | Object containing optional initialisation options, including `source` (array), `context` (Context) and `itemClass` (Class) |
Fires:
Extends
Members
itemClass
The class to use for items in this list (plain JS objects will
automatically be wrapped using this class), defaults to conbo.Hash
length
The number of items in the List
source
The Array used as the source for this List
supro
Similar to `super` in ActionScript or Java, this property enables
you to access properties and methods of the super class prototype,
which is the case of JavaScript is the next prototype up the chain
- Inherited From:
- Source:
Methods
__construct(options)
Constructor: DO NOT override! (Use initialize instead)
Parameters:
Name | Type | Description |
---|---|---|
options |
addEventListener(type, handler, scopeopt, priorityopt, onceopt) → {conbo.EventDispatcher}
Add a listener for a particular event type
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
type |
string | Type of event ('change') or events ('change blur') | ||
handler |
function | Function that should be called | ||
scope |
Object |
<optional> |
Options object (recommended) or the scope in which to run the event handler (deprecated) | |
priority |
number |
<optional> |
0 | The event handler's priority when the event is dispatached (deprecated) |
once |
boolean |
<optional> |
false | Should the event listener automatically be removed after it has been called once? (deprecated) |
- Inherited From:
- Source:
Returns:
A reference to this class instance
bindAll(…methodNameopt) → {this}
Scope all methods of this class instance to this class instance
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
methodName |
string |
<optional> <repeatable> |
Specific method names to bind (all will be bound if none specified) |
- Inherited From:
- Source:
Returns:
- Type
- this
clear()
[Web Storage API] When invoked, will empty all items out of the List, reducing its length to zero
clone()
Create a new List identical to this one.
declarations() → {void}
Declarations is used to declare instance properties used by this class
Parameters:
Type | Attributes | Description |
---|---|---|
* |
<repeatable> |
- Inherited From:
- Source:
Returns:
- Type
- void
destroy() → {void}
Clean everything up ready for garbage collection (you should override in your own classes)
- Inherited From:
- Source:
Returns:
- Type
- void
dispatchChange(propName) → {conbo.EventDispatcher}
Dispatch a change event for one or more changed properties
Parameters:
Name | Type | Description |
---|---|---|
propName |
string | The name of the property that has changed |
- Inherited From:
- Source:
Returns:
A reference to this class instance
dispatchEvent(event) → {conbo.EventDispatcher}
Dispatch the event to listeners
Parameters:
Name | Type | Description |
---|---|---|
event |
conbo.Event | The event to dispatch |
- Inherited From:
- Source:
Returns:
A reference to this class instance
getItem(keyName)
[Web Storage API] When passed a key name, will return that key's value
Parameters:
Name | Type | Description |
---|---|---|
keyName |
number |
getItemAt()
Get the item at the given index; similar to array[index]
hasEventListener(type, handleropt, scopeopt) → {boolean}
Does this object have an event listener of the specified type?
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
string | Type of event (e.g. 'change') | |
handler |
function |
<optional> |
Function that should be called |
scope |
Object |
<optional> |
Options object (recommended) or the scope in which to run the event handler (deprecated) |
- Inherited From:
- Source:
Returns:
True if this object has the specified event listener, false if it does not
- Type
- boolean
initialize() → {void}
Initialize (entry point) is called immediately after the constructor has completed
Parameters:
Type | Attributes | Description |
---|---|---|
* |
<repeatable> |
- Inherited From:
- Source:
Returns:
- Type
- void
key(index)
[Web Storage API] When passed a number n, this method will return n if that index exists or -1 if it does not
Parameters:
Name | Type | Description |
---|---|---|
index |
number |
pop()
Remove an item from the end of the collection.
preinitialize() → {void}
Preinitialize is called before any code in the constructor has been run
Parameters:
Type | Attributes | Description |
---|---|---|
* |
<repeatable> |
- Inherited From:
- Source:
Returns:
- Type
- void
push()
Add an item to the end of the collection.
removeEventListener(typeopt, handleropt, scopeopt) → {conbo.EventDispatcher}
Remove a listener for a particular event type
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
string |
<optional> |
Type of event ('change') or events ('change blur'), if not specified, all listeners will be removed |
handler |
function |
<optional> |
Function that should be called, if not specified, all listeners of the specified type will be removed |
scope |
Object |
<optional> |
Options object (recommended) or the scope in which to run the event handler (deprecated) |
- Inherited From:
- Source:
Returns:
A reference to this class instance
removeItem(keyName)
[Web Storage API] When passed an key name, will remove that key from the List, equivalent to List.splice(keyName, 1)
Parameters:
Name | Type | Description |
---|---|---|
keyName |
number |
setItem(keyName, keyValue)
[Web Storage API] When passed a key name and value, will add that key to the List (i.e. add a new value at that index), or update that key's value if it already exists
Parameters:
Name | Type | Description |
---|---|---|
keyName |
number | |
keyValue |
* |
setItemAt()
Add (or replace) item at given index with the one specified,
similar to array[index] = value;
shift()
Remove an item from the beginning of the collection.
slice()
Slice out a sub-array of items from the collection.
sort(compareFunctionopt)
Force the collection to re-sort itself.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
compareFunction |
function |
<optional> |
Compare function to determine sort order |
splice()
Splice out a sub-array of items from the collection.
toJSON()
The JSON-friendly representation of the List
toString() → {string}
String representation of the current class
- Overrides:
- Source:
Returns:
- Type
- string
unshift()
Add an item to the beginning of the collection.