    import IndexedProperty from 'f.lux/src/IndexedProperty.js'

public class | source

# IndexedProperty

#### Extends:

Property → IndexedProperty

`IndexedProperty` models an Array while limiting the shadow API to the non-mutating `Array` methods, such as `filter()`, `find()`, `indexOf()`, and `map()` to name a few. The IndexedShadow allows for random access and assignment, such as `todos[1].desc`.

The default shadow class is IndexedShadow.

Use `IndexedProperty` when you want to model an array state property without exposing mutating functions like `push()`, `remove()`, and `splice()`. You can then specify a custom shadow api to expose mutation methods that involve implementation logic.

The `_indexed` instance variable exposes a IndexedApi instance for working with properties. Use `this._indexed` to perform `array` mutations, such as `pop()`, `push()`, `shift()`, and `splice()`. For example,

    this._indexed.push("new element");

would append "new element" to the array.

#### See:

- IndexedShadow

## Static Method Summary

Static Public Methods
public static | createClass(shadowType: Object | IndexedShadow, typeCallback: function(type: StateType), initialState: Object): IndexedProperty Factory function for creating an `IndexedProperty` subclass. |
public static | defineType(PropClass: IndexedProperty, ShadowType: Object | IndexedShadow, typeCallback: function(type: StateType), initialState: Object) Factory function for setting up the StateType `type` class variable with an appropriately configured intial state. |

## Constructor Summary

Public Constructor
public | constructor(stateType: *) |

## Inherited Summary

From class Property
public | [_ImplementationClass]: * |
public | [_ShadowClass]: * |
public | [_autoShadow]: * |
public | [_checkpoint]: {"data": *} |
public | [_impl]: * |
public | [_initialState]: * |
public | [_mixins]: *[] |
public | [_parent]: * |
public | [_pid]: * |
public | [_readonly]: * |
public | [_shader]: * |
public | [_stateType]: * |
public | [_store]: * |
public | $$(): Property Use this.$$() in shadow methods to get access to the property. |
public | autoShadow(): boolean Gets if autoshadowing is enabled for this property. |
public | checkpoint() Copies the current actual state for later reset using Property#resetToCheckpoint. |
public | clearCheckpoint() Clears an existing checkpoint created using Property#checkpoint. |
public | create$(impl: *): Access Creates the object to be assigned to the shadow.$ property. |
public | dotPath(): string Gets the path from root property using a dot (`.`) separator. |
public | getCheckpoint(): * Gets the checkpoint state previously recorded using Property#checkpoint. |
public | getInitialState(state: *): * Gets the initial state for a property at the beginning of the property mounting process. |
public | hasCheckpoint(): boolean Gets if an existing checkpoint has be created using Property#checkpoint. |
public | initialState(): * Gets the result from StateType#computeInitialState. |
public | isActive(): boolean Gets if the property is currently shadowing an actual state property. |
public | isIsolated(): boolean Gets if property is an actual isolated property managed by the store. |
public | isReadonly(): boolean Gets if the property allows for assignment through the shadow state, ie `todo.desc = "go skiing"`. |
public | isRoot(): boolean Gets if this is the shadow state root property. |
public | name(): string | number The property name by which this property is referenced by the Property.parent. |
public | nextState(): * Gets what the actual state for this property will be after the Store updates all pending actions. |
public | owner(): Property Gets the object containing or managing this property. |
public | parent(): Property Gets the parent property. |
public | parentShadow(): Shadow Gets the parent's shadow property. |
public | path(): [] Gets the Property#name components from the root property to this property. |
public | pid(): number Gets the unique f.lux ID for this property. |
public | propertyChildInvalidated(childProperty: Property, sourceProperty: Property) A child property or one of its descendents wil be changing state. |
public | propertyDidShadow() Invoked by the f.lux shadowing process after a property initially shadows a state property. |
public | propertyDidUpdate() Invoked by the f.lux shadowing process after a property is reshadowed. |
public | propertyWillShadow() Invoked by the f.lux shadowing process just before a property initially shadows a state property. |
public | propertyWillUnshadow() Invoked by the f.lux shadowing process just before a property will be removed from the shadow state. |
public | resetToCheckpoint() Replaces the current property state with a checkpoint state previously recorded using Property#checkpoint. |
public | root(): Property Gets the shadow state root property for the Store managing this property. |
public | rootShadow(): Shadow Gets the root shadow state for the Store managing this property. |
public | setAutoshadow(auto: boolean): * Sets the auto shadow property flag. |
public | setImplementationClass(ImplClass: *) |
public | setInitialState(state: *): Property Explicitly sets an initial state that will be used if the state tree does not have a value for this property. |
public | setReadonly(readonly: *) Sets the readonly flag which will prevent an assignment from changing the value. |
public | setShadowClass(ShadowClass: Shadow) Sets the class to be used for the shadow api |
public | shader(state: *): * Gets the Shader instance for this property. |
public | shadowClass(): * Returns the Shadow subclass used to virtualize the state property. |
public | slashPath(): string Gets the path from root property using a slash (`/`) separator. |
public | state(): * Gets the actual state being shadowed. |
public | stateType(): * Gets the StateType used for creating this property. |
public | store(): * Gets the {@Link Store} containing the application state. |
public | touch() Triggers a reshadow of the properties shadow state. |
public | typeName(): * Gets this property's StateType.typeName value. |
public | update(callback: function) Makes changes to the next proeprty state. |

## Static Public Methods

### public static createClass(shadowType: Object | IndexedShadow, typeCallback: function(type: StateType), initialState: Object): IndexedProperty source

Factory function for creating an `IndexedProperty` subclass. The generated class will have the `type` StateType descriptor set upon return.

Example usage:

    class SomeShadow extends IndexedShadow {
    // definition here
    }

    export default IndexedProperty.createClass(SomeShadow, type => {
    // configure type variable
    });

#### Params:

Name | Type | Attribute | Description

shadowType

Object | IndexedShadow

- optional
- default: {}

`IndexedShadow` subclass or object literal api definition. If object literal specified, each property and function is mapped onto a Shadow subclass.

typeCallback

function(type: StateType)

- optional

a callback function that will be passed the StateType spec for additional customization, such as setting autoshadow, initial state, or readonly.

initialState

Object

- optional

=[] - the initial state for the new property.

#### Return:

IndexedProperty | newly defined `IndexedProperty` subclass.

### public static defineType(PropClass: IndexedProperty, ShadowType: Object | IndexedShadow, typeCallback: function(type: StateType), initialState: Object) source

Factory function for setting up the StateType `type` class variable with an appropriately configured intial state.

Example usage:

    export default class SomeProperty extends IndexedProperty {
    // implement property here
    }

    class SomeShadow extends IndexedShadow {
    // implement shadow api here
    }

    MapProperty.defineType(SomeProperty, SomeShadow, type => {
    // configure type variable
    });

#### Params:

Name | Type | Attribute | Description
PropClass | IndexedProperty |  | IndexedProperty subclass

ShadowType

Object | IndexedShadow

- optional

`IndexedShadow` subclass or object literal api definition. If object literal specified, each property and function is mapped onto a Shadow subclass.

typeCallback

function(type: StateType)

- optional

a callback function that will be passed the StateType spec for additional customization, such as setting autoshadow, initial state, or readonly.

initialState

Object

- optional
- default: []

the initial state for the new property.

## Public Constructors

### public constructor(stateType: *) source

If a StateType is not passed to this constructor then one is located using StateType.from thus ensuring the f.lux shadowing process is defined for this property.

#### Override:

Property#constructor

#### Params:

Name | Type | Attribute | Description
stateType | * |  |