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

public class | source

# Access

#### Direct Subclass:

IsolatedAccess, ModelAccess, ShadowModelAccess

The base class for `Shadow.$()` method used for obtaining f.lux contextual information concerning a non-primitive shadow state property.

The most commonly used methods include:

- Access#dotPath
- Access#property
- Access#pid
- Access#state
- Access#store
- Access#waitFor

This class provides access to the experimental Property checkpointing api. Checkpointing allows the state to be recorded at a point in time and then later reset to that point. This is handy when a form may accept changes and then allow the user to cancel the edit session.

#### See:

- Shadow

## Constructor Summary

Public Constructor
public | constructor(impl: *) |

## Member Summary

Public Members
public | [_impl]: * |

## Method Summary

Public Methods
public | checkpoint() Copies the current actual state for later reset using Property#resetToCheckpoint. |
public | clearCheckpoint() Clears an existing checkpoint created using Property#checkpoint. |
public | dotPath(): string Gets the path from root property using a dot (`.`) separator. |
public | getCheckpoint(): Object | Array Gets the checkpoint state previously recorded using Property#checkpoint. |
public | hasCheckpoint(): boolean Gets if an existing checkpoint has be created using Property#checkpoint. |
public | isActive(): boolean Gets if the shadow state property is proxying the current actual state contained in the f.lux store. |
public | isReadonly(): boolean Gets if the property allows for assignment through the shadow state, ie `todo.desc = "go skiing"`. |
public | isValid(): boolean Gets if the shadow property has experienced a mutation action. |
public | latest(): Shadow Gets the current shadow state for this property. |
public | nextState(): Object | Array Gets the next actual state for this property following any pending actions. |
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 | property(): Property Gets the Property managing this shadow property. |
public | resetToCheckpoint() Replaces the current property state with a checkpoint state previously recorded using Property#checkpoint. |
public | rootShadow(): Shadow Gets the top-level shadow from the Store containing this shadow state property. |
public | shadow(): * |
public | slashPath(): string Gets the path from root property using a slash (`/`) separator. |
public | state(): Object | Array Gets the actual state being shadowed. |
public | store(): Store Gets the {@Link Store} containing the application state. |
public | update(callback: *) Performs an update on the state values. |
public | waitFor(callback: function(shadow: Shadow)) Registers a one-time no argument callback to be invoked after the next Store state change. |

## Public Constructors

### public constructor(impl: *) source

#### Params:

Name | Type | Attribute | Description
impl | * |  |

## Public Members

### public [_impl]: * source

## Public Methods

### public checkpoint() source

Copies the current actual state for later reset using Property#resetToCheckpoint. An existing checkpoint will take precedence over subsequent calls.

### public clearCheckpoint() source

Clears an existing checkpoint created using Property#checkpoint.

### public dotPath(): string source

Gets the path from root property using a dot (`.`) separator. Suitable for using with the lodash `result()` function.

#### Return:

string | path with each component joined by a `.`

#### See:

- https://lodash.com/docs/4.17.4#result

### public getCheckpoint(): Object | Array source

Gets the checkpoint state previously recorded using Property#checkpoint.

#### Return:

Object | Array | the checkpoint data if checkpoint is set.

### public hasCheckpoint(): boolean source

Gets if an existing checkpoint has be created using Property#checkpoint.

#### Return:

boolean | true if a checkpoint has been recorded.

### public isActive(): boolean source

Gets if the shadow state property is proxying the current actual state contained in the f.lux store.

#### Return:

boolean | `true` if actively proxying the state.

### public isReadonly(): boolean source

Gets if the property allows for assignment through the shadow state, ie `todo.desc = "go skiing"`. The readonly attribute is hierarchically determined through the parent property if not explicitly set.

#### Return:

boolean | true if assignment is not allowed

### public isValid(): boolean source

Gets if the shadow property has experienced a mutation action. This method will return `true` and Access#isActive may also return true if the f.lux store has not yet been transitioned to the next state.

#### Return:

boolean | `true` if the state has not been changed.

### public latest(): Shadow source

Gets the current shadow state for this property. The shadow state referenced by this access object could be stale if a javascript closure has a previous reference and then performed an asynchronous operation like a network request.

#### Return:

Shadow

### public nextState(): Object | Array source

Gets the next actual state for this property following any pending actions.

#### Return:

Object | Array

### public path(): [] source

Gets the Property#name components from the root property to this property.

#### Return:

[] | array where each name component is either a `string` or `number` depending on the each parent component's type.

### public pid(): number source

Gets the unique f.lux ID for this property.

#### Return:

number | the id

### public property(): Property source

Gets the Property managing this shadow property.

#### Return:

Property

### public resetToCheckpoint() source

Replaces the current property state with a checkpoint state previously recorded using Property#checkpoint. The checkpoint is cleared.

### public rootShadow(): Shadow source

Gets the top-level shadow from the Store containing this shadow state property.

#### Return:

Shadow

### public shadow(): * source

#### Return:

*

### public slashPath(): string source

Gets the path from root property using a slash (`/`) separator.

#### Return:

string | path with each component separated by a `/`

### public state(): Object | Array source

Gets the actual state being shadowed.

#### Return:

Object | Array

### public store(): Store source

Gets the {@Link Store} containing the application state.

#### Return:

Store

### public update(callback: *) source

Performs an update on the state values.

The callback should be pure and have the form:

    callback(nextState) : nextState

- or -

    callback(nextState) : { name, nextState }

The `nextState` parameter is a javascript object (not a `Shadow`) that represents the next state starting from the current state and having all the actions in the current tick applied to it before this `update()` call.

The callback should return an object with the following properties:

- `name` - a stort moniker identifying the update call purpose. This will passed to the store middleware. This value is optional with the default value being '[path].$().update()'.
- `nextState` - the value for the next state after the update functionality.

#### Params:

Name | Type | Attribute | Description
callback | * |  |

### public waitFor(callback: function(shadow: Shadow)) source

Registers a one-time no argument callback to be invoked after the next Store state change.

#### Params:

Name | Type | Attribute | Description
callback | function(shadow: Shadow) |  | a callback to be invoked after all pending changes have been reflected in the shadow state.