ConanState

The class ConanState contains the following methods:

connectMap <PROPS>

this method allows connecting a Conan state with a React component, using a mapper function to describe the mapping

Input

‚Äč

toConnect

Type: React.ComponentType required

the component type we want to connect

mapper

Type: IBiFunction<DATA, ACTIONS, PROPS> required

A function that receives DATA and ACTIONS. It describes how the PROPS will be connected

Returns

‚Äč

ReactElement

A connected React element

‚Äč

connectData

this method allows connecting all Conan state data with a React component,

Input

‚Äč

toConnect

Type: React.ComponentType required

the component type we want to connect

Returns

‚Äč

ReactElement

A connected React element

‚Äč

connect

‚ÄĆthis method allows connecting all Conan state with a React component

Input

‚ÄčTitle

toConnect

Type: React.ComponentType<ConnectedState<DATA, ACTIONS>> required

the component type we want to connect

Returns

‚ÄčTitle

ReactElement<ConnectedState>

A React element with the whole ConnectedState

‚Äč

connectLive

‚ÄĆthis method allows producing connected react elements by accepting a renderer function, which receives the ConanState data and actions.

Input

‚ÄčTitle

renderer

Type: IBiFunction<DATA, ACTIONS, ReactElement | ReactElement[]> required

The render function that will produce out connected react elements

fallbackValue

Type: DATA optional

default DATA in case nothing is there when initialised

Returns

‚ÄčTitle

ReactElement

A State connected React element

‚Äč

‚Äč

addDataReaction

‚ÄĆthis method can be uses to add a custom data reaction a un ConanState

Input

‚ÄčTitle

def

Type: DataReactionDef<DATA> required

the custom data reaction definition

Returns

‚ÄčTitle

DataReactionLock

TBC: Alberto que co√Īo es esto

‚Äč

‚Äč

do

‚ÄĆthis method returns the actions available for this ConanState

Input

‚ÄčTitle

void

‚Äč

Returns

‚ÄčTitle

DataReactionLock

actions available for this ConanState

‚Äč

‚Äč

getData

‚ÄĆthis method returns the current data of this ConanState

Input

‚ÄčTitle

void

‚Äč

Returns

‚ÄčTitle

DATA

current data of this ConanState

‚Äč

filter

‚ÄĆthis method returns a filtered ConanState

Input

‚ÄčTitle

mapper

Type: (current: DATA, previous: DATA) => boolean required

the filter function that receives the current and previous DATA and has to return a boolean

Returns

‚ÄčTitle

ConanState<DATA>

The resulting filtered ConanState

‚Äč

‚Äč

map<T>

‚ÄĆthis method returns a remapped ConanState

Input

‚ÄčTitle

mapper

Type: IFunction<DATA, T> required

the mapper function that receives the current DATA and has to return the new remmapped ConanState

Returns

‚ÄčTitle

ConanState<DATA>

The resulting remapped ConanState

‚Äč

‚Äč

merge<T, TO_MERGE>

‚ÄĆthis method returns a remapped ConanState

Input

‚ÄčTitle

toMerge$

Type: ConanState<TO_MERGE, any> required

the ConanState that we want to merge with

merger

Type: ITriFunction<DATA, TO_MERGE, T, T> required

the function that describes the merge operation

Returns

‚ÄčTitle

ConanState<T>

The resulting merged ConanState

‚Äč

‚Äč

tuple<TO_MERGE>

‚ÄĆthis method combined two states into one

Input

‚ÄčTitle

toMerge$

Type: ConanState<TO_MERGE, any> required

the ConanState that we want to merge with

Returns

‚ÄčTitle

ConanState<[DATA, TO_MERGE]>

The resulting combined ConanState

‚Äč

‚Äč

asyncState

‚ÄĆthis method gives access to the async state data and actions

Input

‚ÄčTitle

void

‚Äč

Returns

‚ÄčTitle

ConanState<MonitorInfo, MonitorActions>

the async state data and actions

‚Äč

metaFlow

‚ÄĆ‚ÄĆthis method gives access to the state meta flow

Input

‚ÄčTitle

void

‚ÄčContent

Returns

‚ÄčTitle

ConanFlow<MetaStatuses, MetaMutators>

the meta Conan flow for this state

‚Äč

combine<T extends {}, ACTIONS = void>

‚ÄĆthis method combined two states into one

Input

‚ÄčTitle

name

Type: String required

The name for the combined ConanState that will be returned

fromState

Type: {[KEY in keyof T]: ConanState<T[KEY], any>} required

the ConanState that we want to combine

pipeThreadDef

Type: PipeThreadDef<T, {}, ACTIONS> optional

TBC: Alberto que co√Īo es esto

Returns

‚ÄčTitle

ConanState<T, ACTIONS>

The resulting combined ConanState

‚Äč

getEvents

‚ÄĆthis method gives access to the ConanState main thread events

Input

‚ÄčTitle

void

‚Äč

Returns

‚ÄčTitle

FlowEventsTracker<{ nextData: DATA}>

all the events that have gone through the state main thread

‚Äč

‚Äč

getName

‚ÄĆthis method returns the ConantState name

Input

‚ÄčTitle

void

‚Äč

Returns

‚ÄčTitle

string

the ConanState name

‚Äč

‚Äč

openTransaction

‚ÄĆthis method allows to open a transaction

Input

‚ÄčTitle

name

Type: String required

The name of the transaction to create to be used for internal logging only

Returns

‚ÄčTitle

void

‚Äč

‚Äč

closeTransaction

‚ÄĆthis method allows to close the current transaction

Input

‚ÄčTitle

callback

Type: IConsumer<DATA> optional

callback to be invoked once the transaction is closed

Returns

‚ÄčTitle

void

‚Äč