Stack
A Stack isn't a stream, but can be used in conjunction with streams, actions, and
transformers to make debugging much easier. Using pushAction
, 'pushState,
pushTransformer, and
pushLog, you can create a log of state changes and
their causes. Calling
dump,
dumpToLog, and
dumpWhen` will give you control
over when to view to stack.
Constructor Summary
Public Constructor | ||
public |
constructor(size: number, debug: boolean): Stack constructor - A stack takes a size for the stack and a boolean to determine whether the stack should be enabled on creation. |
Member Summary
Public Members | ||
public |
debug: * |
|
public set |
set size - sets the size of the stack. |
|
public get |
get size - getter for returning the current size of the stack. |
Method Summary
Public Methods | ||
public |
dump(): Immutable.List dump - Returns the stack, removing any undefined items. |
|
public |
dumpToLog(stateAccessor: array) dumpToLog - When dumpToLog is called, it logs out the current stack to the console, formatting the different types of items in the stack for clarity. |
|
public |
dumpWhen - adds a test function to the stack that will run whenever new state is added to the stack. |
|
public |
pushAction(fnName: string, args: object) pushAction - Adds an action to the stack. |
|
public |
pushLog - Adds a text log to the stack. |
|
public |
pushState - Adds a state Map to the stack. |
|
public |
pushTransformer(fnName: string, args: object) pushTransformer - Adds a transformer to the stack. |
Public Constructors
Public Members
public debug: * source
Public Methods
public dump(): Immutable.List source
dump - Returns the stack, removing any undefined items.
Return:
Immutable.List | the stack. |
public dumpToLog(stateAccessor: array) source
dumpToLog - When dumpToLog is called, it logs out the current stack to the console, formatting the different types of items in the stack for clarity. It takes an optional array for only logging a particular part of the state objects.
Params:
Name | Type | Attribute | Description |
stateAccessor | array | takes an array of strings for logging only a certain part of the state |
public dumpWhen(testFn: function, callbackFn: function) source
dumpWhen - adds a test function to the stack that will run whenever new state is added to the stack. The test function takes the state as an argument and returns a boolean. If the test function returns true, it will then run the callback function, passing the current stack as an argument.
public pushLog(text: string) source
pushLog - Adds a text log to the stack.
Params:
Name | Type | Attribute | Description |
text | string | The text to be added to the stack. |