Class: PageStateManagerImpl<S>
@ima/core.PageStateManagerImpl
The implementation of the PageStateManager interface.
Type parameters
Name | Type |
---|---|
S | extends PageState = {} |
Hierarchy
↳
PageStateManagerImpl
Constructors
constructor
• new PageStateManagerImpl<S
>(dispatcher
)
Initializes the page state manager.
Type parameters
Name | Type |
---|---|
S | extends PageState = {} |
Parameters
Name | Type | Description |
---|---|---|
dispatcher | Dispatcher | Dispatcher fires events to app. |
Overrides
Defined in
packages/core/src/page/state/PageStateManagerImpl.ts:40
Properties
_cursor
• Private
_cursor: number
= -1
Defined in
packages/core/src/page/state/PageStateManagerImpl.ts:25
_dispatcher
• Private
_dispatcher: Dispatcher
Defined in
packages/core/src/page/state/PageStateManagerImpl.ts:26
_ongoingTransaction
• Private
_ongoingTransaction: boolean
= false
Defined in
packages/core/src/page/state/PageStateManagerImpl.ts:27
_statePatchQueue
• Private
_statePatchQueue: (null
| S
| Pick
<S
, any
>)[] = []
Defined in
packages/core/src/page/state/PageStateManagerImpl.ts:28
_states
• Private
_states: S
[] = []
Defined in
packages/core/src/page/state/PageStateManagerImpl.ts:29
onChange
• Optional
onChange: (newState
: S
) => void
Type declaration
▸ (newState
): void
Parameters
Name | Type |
---|---|
newState | S |
Returns
void
Inherited from
Defined in
packages/core/src/page/state/PageStateManager.ts:7
Accessors
$dependencies
• Static
get
$dependencies(): typeof Dispatcher
[]
Returns
typeof Dispatcher
[]
Defined in
packages/core/src/page/state/PageStateManagerImpl.ts:31
Methods
_callOnChangeCallback
▸ _callOnChangeCallback(newState
): void
Call registered callback function on (@link onChange) with newState.
Parameters
Name | Type |
---|---|
newState | S |
Returns
void
Defined in
packages/core/src/page/state/PageStateManagerImpl.ts:175
_eraseExcessHistory
▸ _eraseExcessHistory(): void
Erase the oldest state from storage only if it exceed max defined size of history.
Returns
void
Defined in
packages/core/src/page/state/PageStateManagerImpl.ts:157
_pushToHistory
▸ _pushToHistory(newState
): void
Push new state to history storage.
Parameters
Name | Type |
---|---|
newState | S |
Returns
void
Defined in
packages/core/src/page/state/PageStateManagerImpl.ts:167
beginTransaction
▸ beginTransaction(): void
Starts queueing state patches off the main state. While the transaction
is active every setState
call has no effect on the current state.
Note that call to getState
after the transaction has begun will
return state as it was before the transaction.
Returns
void
Overrides
PageStateManager.beginTransaction
Defined in
packages/core/src/page/state/PageStateManagerImpl.ts:106
cancelTransaction
▸ cancelTransaction(): void
Cancels ongoing transaction. Uncommitted state changes are lost.
Returns
void
Overrides
PageStateManager.cancelTransaction
Defined in
packages/core/src/page/state/PageStateManagerImpl.ts:148
clear
▸ clear(): void
Clears the state history.
Returns
void
Overrides
Defined in
packages/core/src/page/state/PageStateManagerImpl.ts:49
commitTransaction
▸ commitTransaction(): void
Applies queued state patches to the main state. All patches are squashed
and applied with one setState
call.
Returns
void
Overrides
PageStateManager.commitTransaction
Defined in
packages/core/src/page/state/PageStateManagerImpl.ts:123
getAllStates
▸ getAllStates(): S
[]
Returns the recorded history of page states. The states will be chronologically sorted from the oldest to the newest.
Note that the implementation may limit the size of the recorded history, therefore the complete history may not be available.
Returns
S
[]
The recorded history of page states.
Overrides
Defined in
packages/core/src/page/state/PageStateManagerImpl.ts:92
getState
▸ getState(): S
Returns the current page state.
Returns
S
The current page state.
Overrides
Defined in
packages/core/src/page/state/PageStateManagerImpl.ts:85
getTransactionStatePatches
▸ getTransactionStatePatches(): (null
| S
| Pick
<S
, any
>)[]
Returns queueing state patches off the main state from the begin of transaction.
Returns
(null
| S
| Pick
<S
, any
>)[]
State patches from the begin of transaction.
Overrides
PageStateManager.getTransactionStatePatches
Defined in
packages/core/src/page/state/PageStateManagerImpl.ts:99
setState
▸ setState<K
>(patchState
): number
| void
Sets a new page state by applying the provided patch to the current state.
Type parameters
Name | Type |
---|---|
K | extends string | number | symbol |
Parameters
Name | Type |
---|---|
patchState | null | S | Pick <S , K > |
Returns
number
| void