Reference Source
public class | source

Stateable

Extends:

LoggableErrorableSettingsable → Stateable

Direct Subclass:

Instance

Stateable base class.

Example:

API:
		->get_initial_state():plain object - get state at creation.
		->get_state():plain object - get current state.
		->get_state_store():object - get state store.
		->get_state_path():array|string - get state path into store.
		->get_state_value(arg_key_or_path, arg_default_value=undefined):any - get a state value at path.

		->handle_state_change(arg_previous_state, arg_new_state):nothing - handle state changes (to be implemented in sub classes)
		->register_state_value_change_handle(arg_path, arg_listener):nothing - Register a state value change listener.

		->dispatch_action(arg_action_type, arg_options):nothing - dispatch state changes actions.

		->get_name():string - get instance name.

Constructor Summary

Public Constructor
public

constructor(arg_settings: Immutable.Map | object, arg_runtime: object, arg_state: object, arg_log_context: string, arg_logger_manager: LoggerManager): nothing

Creates an instance of Stateable: an object with an observable mutable state.

Member Summary

Public Members
public

Class type flag.

public

state_path: array

State path in runtime state.

Private Members
private

Initial state.

private

_runtime: Runtime

Runtime isntance.

private

State store.

private

State changes handlers.

Method Summary

Public Methods
public

dispatch_action(arg_action_type: string | object, arg_options: object | undefined): nothing

Dispatch a state action.

public

get_initial_state(): Immutable.Map

Get initial state, an immutable object from a Redux data store.

public

Get name.

public

Get runtime instance.

public

get_state(): Immutable.Map

Get current state, an immutable object from a Redux data store.

public

Get current state, an immutable object from a Redux data store.

public

get_state_path(): array

Get state path into a Redux data store.

public

Get state store.

public

get_state_value(arg_key_or_path: string | array, arg_default_value: any): any

Get a state entry.

public

handle_state_change(arg_previous_state: Immutable.Map, arg_new_state: Immutable.Map): nothing

Handle component state changes.

public

register_state_value_change_handle(arg_path: string | array, arg_listener: string | function): nothing

Register a state value change listener.

Inherited Summary

From class Loggable
public

Log context.

public

Class type flag.

public

Trace is enabled for this flag.

private

Logger manager instance (default undefined)

public

debug(args: string | array): nothing

Trace DEBUG formatted message.

public

disable_trace(): nothing

Disable traces.

public

enable_trace(): nothing

Enable traces.

public

enter_group(arg_group: string): nothing

Trace INFO message on "enter trace group".

public

error(args: string | array): nothing

Trace ERROR formatted message.

public

Define get class name method for non Instance classes.

public

Get instance context.

public

Get logger manager.

public

Define get instance name method for non Instance classes.

public

Get trace flag.

public

info(args: string | array): nothing

Trace INFO formatted message.

public

leave_group(arg_group: string): nothing

Trace INFO message on "leave trace group".

public

separate_level_1(): nothing

Trace INFO trace level 1 separator.

public

separate_level_2(): nothing

Trace INFO trace level 2 separator.

public

separate_level_3(): nothing

Trace INFO trace level 3 separator.

public

set_trace(arg_value: boolean): nothing

Set trace flag.

public

should_trace(arg_traces_cfg: object): boolean

Calculate should trace flag.

public

should_trace_class(arg_traces_cfg: object): boolean

Calculate should trace flag for classes.

public

should_trace_collection_item(arg_traces_cfg: object, arg_collection_name: string, arg_this_item_accessor: string): boolean

Calculate should trace flag for given collection of names or patterns.

public

should_trace_module(arg_traces_cfg: object): boolean

Calculate should trace flag for modules.

public

should_trace_name(arg_traces_cfg: object): boolean

Calculate should trace flag for instances names.

public

Toggle trace flag.

public

Update trace enabled flag.

public

warn(args: string | array): nothing

Trace WARN formatted message.

From class Errorable
private

Error text (default null).

private

Has error flag (default false).

public

error(arg_msg: string): nothing

Set an error.

public

Default helper for "not implemented" error.

public

Get error message.

public

Test is an error is set.

From class Settingsable
public

$settings: object | Immutable.Map

Instance settings (default undefined).

public

Class type flag.

public

get_setting(arg_name: string | array, arg_default: any): any

Get a value in settings for given key.

public

get_setting_js(arg_name: string | array, arg_default: any): any

Get a value in settings for given key.

public

get_settings(): Immutable.Map

Get instance settings.

public

get_settings_js(): Immutable.Map

Get instance settings.

public

has_setting(arg_name: string): boolean

Test if a key exists in settings.

public

set_setting(arg_name: string, arg_value: any): nothing

Set a value in settings for given key.

public

set_settings(arg_settings: Immutable.Map): nothing

Set instance settings.

Public Constructors

public constructor(arg_settings: Immutable.Map | object, arg_runtime: object, arg_state: object, arg_log_context: string, arg_logger_manager: LoggerManager): nothing source

Creates an instance of Stateable: an object with an observable mutable state.

Override:

Settingsable#constructor

Params:

NameTypeAttributeDescription
arg_settings Immutable.Map | object

settings plain object

arg_runtime object

client runtime.

arg_state object

component state.

arg_log_context string

context of traces of this instance (optional).

arg_logger_manager LoggerManager

logger manager object (optional).

Return:

nothing

Public Members

public is_stateable: boolean source

Class type flag.

public state_path: array source

State path in runtime state.

Private Members

private _initial_state: object source

Initial state.

private _runtime: Runtime source

Runtime isntance.

private _state_store: StateStore source

State store.

private _state_value_listeners: array source

State changes handlers.

Public Methods

public dispatch_action(arg_action_type: string | object, arg_options: object | undefined): nothing source

Dispatch a state action.

Params:

NameTypeAttributeDescription
arg_action_type string | object

action type string or action object.

arg_options object | undefined

action options object (optional).

Return:

nothing

public get_initial_state(): Immutable.Map source

Get initial state, an immutable object from a Redux data store.

Return:

Immutable.Map

component state.

public get_name(): string source

Get name.

Override:

Loggable#get_name

Return:

string

instance name.

public get_runtime(): RuntimeBase source

Get runtime instance.

Return:

RuntimeBase

public get_state(): Immutable.Map source

Get current state, an immutable object from a Redux data store.

Return:

Immutable.Map

component state.

public get_state_js(): object source

Get current state, an immutable object from a Redux data store.

Return:

object

component state.

public get_state_path(): array source

Get state path into a Redux data store.

Return:

array

component state path.

public get_state_store(): object source

Get state store.

Return:

object

State store.

public get_state_value(arg_key_or_path: string | array, arg_default_value: any): any source

Get a state entry.

Params:

NameTypeAttributeDescription
arg_key_or_path string | array

key string or strings path array.

arg_default_value any

returned value on not found value result (optional)(default:undefined).

Return:

any

js value (plain object, number, string, array, boolean)

public handle_state_change(arg_previous_state: Immutable.Map, arg_new_state: Immutable.Map): nothing source

Handle component state changes.

Params:

NameTypeAttributeDescription
arg_previous_state Immutable.Map

previous state map.

arg_new_state Immutable.Map

new state map.

Return:

nothing

public register_state_value_change_handle(arg_path: string | array, arg_listener: string | function): nothing source

Register a state value change listener.

Params:

NameTypeAttributeDescription
arg_path string | array

component state value path array or string with a dot separator.

arg_listener string | function

state value change listener, function or method name.

Return:

nothing