Function
| Static Public Summary | ||
| public |
BindHandlers(args: ...*): * Creates a decorator for binding action handlers to a store. |
|
| public |
bindActions(args: ...*): * Decorates a store with any number of viewAction definitions. |
|
| public |
bindCalls(args: ...*): * Decorates a store with any number of call definitions. |
|
| public |
bindHandlers(actions: *, handlers: ...*): * Decorates a store with any number of action handlers. |
|
| public |
callFactory(name: *, objectPattern1: {"namespace": *, "defaultActions": *, "actions": *, "logger": *}): {"name": *, "actions": *, "create": *, "createActions": *} |
|
| public |
callSeries(calls: array, options: object): promise Retuns a promise and executes a series of calls. |
|
| public |
A component decorator for connecting to immutable stores. |
|
| public |
connectAlternative(store: *, mapStateToProps: *, WrappedComponent: *): * |
|
| public |
createActions(namespace: string, actions: array<string>): object Creates simple (data-pass-through) actions with a namespace. |
|
| public |
createLogger(name: *): {"log": *, "info": *, "warn": *, "error": *, "trace": *} |
|
| public |
createStore(displayName: *, objectPattern1: {"alt": *, "state": *, "calls": *, "sources": *, "viewActions": *}): * |
|
| public |
|
|
| public |
|
|
| public |
flatten(args: ...*): * Reduces a mixed array to a flat one. |
|
| public |
getAltInstance(): * |
|
| public |
getLevel(): * |
|
| public |
getSources(calls: *): * |
|
| public |
|
|
| public |
handlerFactory(action: *, objectPattern1: {"namespace": *, "logger": *}): {"create": *} |
|
| public |
|
|
| public |
setAltInstance(alt: *) |
|
| public |
setLevel(value: *) |
|
| public |
validateCreator(call: *, logger: *): * |
|
| public |
validateDefinition(definition: *, logger: *): * |
|
| public |
validateHandler(handler: *, logger: *): * |
|
Static Public
public BindHandlers(args: ...*): * source
import BindHandlers from '@xailabs/altx/src/BindHandlers.js'Creates a decorator for binding action handlers to a store. A binding is created for each action that has a matching handler method mapping.
The decorator takes any number of action handler definitions as arguments and applies their bindings after concatinating them to a flat list, so you can pass either of these:
- an array of handler definitions
- any number of array of handler definitions
- any number of handlerdefinitions without arrays
- any mixed variation
See manual/usage/action-handlers.md for more on this topic.
Params:
| Name | Type | Attribute | Description |
| args | ...* |
Return:
| * |
public bindActions(args: ...*): * source
import bindActions from '@xailabs/altx/src/decorators/bindActions.js'Decorates a store with any number of viewAction definitions.
Params:
| Name | Type | Attribute | Description |
| args | ...* |
Return:
| * |
public bindCalls(args: ...*): * source
import bindCalls from '@xailabs/altx/src/decorators/bindCalls.js'Decorates a store with any number of call definitions.
Params:
| Name | Type | Attribute | Description |
| args | ...* |
Return:
| * |
public bindHandlers(actions: *, handlers: ...*): * source
import bindHandlers from '@xailabs/altx/src/decorators/bindHandlers.js'Decorates a store with any number of action handlers.
Params:
| Name | Type | Attribute | Description |
| actions | * | ||
| handlers | ...* |
Return:
| * |
public callFactory(name: *, objectPattern1: {"namespace": *, "defaultActions": *, "actions": *, "logger": *}): {"name": *, "actions": *, "create": *, "createActions": *} source
import callFactory from '@xailabs/altx/src/callFactory.js'Params:
| Name | Type | Attribute | Description |
| name | * | ||
| objectPattern1 | {"namespace": *, "defaultActions": *, "actions": *, "logger": *} |
|
Return:
| {"name": *, "actions": *, "create": *, "createActions": *} |
public callSeries(calls: array, options: object): promise source
import callSeries from '@xailabs/altx/src/callSeries.js'Retuns a promise and executes a series of calls. Uses a timeout initially so that we don't run into errors when still in the middle of a dispatch.
import {callSeries} from 'shared/flux';
Return:
| promise | A promise that will be resolved when all calls succeeded or rejected if one call failed |
public connect(definitions: Array<{store: AltStore, props: Array<string>}>): *{store:> source
import connect from '@xailabs/altx/src/decorators/connect.js'A component decorator for connecting to immutable stores.
Basically a wrapper around alt/utils/connectToStores.
Adds the necessary static methods getStores() and getPropsFromStores() to the decorated component.
- Supports multiple stores.
- Supports a simplified, string-based access to stores, with optional renaming of props.
- Supports more flexible, redux-like access to stores using mapper functions.
String notation
Return:
| * |
Example:
@connect([{store: MyStore, props: ['myValue', 'anotherValue']}])
export default class MyComponent extends React.Component {
render() {
const {myValue, anotherValue} = this.props;
...
}
}
You can rename props using the ` as ` alias syntax
@connect([{
store: PeopleStore,
props: ['items as people']
}, {
store: ProductStore,
props: ['items as products']
}])
export default class MyComponent extends React.Component {
render() {
// this.props.people, this.props.products, ...
}
}
### Function notation
Use mapper functions instead of strings in order to manually retrieve store values.
The function receives the store state and the component props.
@connect([{
store: MyStore,
props: (state, props) => {
return {
item: state.get('items').filter(item => item.get('id') === props.id)
}
}
}])
export default class MyComponent extends React.Component {
render() {
const item = this.props.item;
}
}
Technically, you could also mix all access methods, but this defeats the purpose of simple access:
@connect([{
store: MyStore,
props: ['someProp', 'anotherProp', (state, props) => {
return {
item: state.get('items').filter(item => item.get('id') === props.id)
}
}, 'some.nested.value as foo']
}])
export default class MyComponent extends React.Component {
...
}
There are however valid usecase for mixing access methods. For example, you might have keys that themselves contain dots.
For example, that is the case when using `validate.js` with nested constraints and keeping validation results in the store.
There might be an `errors` map in your storewith keys like `user.address.street`. In such a case you wouldn't be able to access those values because the dots do not
represent the actual keyPath in the tree:
@connect([{
store,
props: ['user.address.street', (state) => ({errors: state.getIn(['errors', 'user.address.street'])})]
}])
public connectAlternative(store: *, mapStateToProps: *, WrappedComponent: *): * source
import {connectAlternative} from '@xailabs/altx/src/decorators/connect.js'Params:
| Name | Type | Attribute | Description |
| store | * | ||
| mapStateToProps | * | ||
| WrappedComponent | * |
Return:
| * |
public createActions(namespace: string, actions: array<string>): object source
import createActions from '@xailabs/altx/src/createActions.js'Creates simple (data-pass-through) actions with a namespace.
Basically just like alt.generateActions, but within a given namespace instead of 'global'.
public createLogger(name: *): {"log": *, "info": *, "warn": *, "error": *, "trace": *} source
import {createLogger} from '@xailabs/altx/src/utils/logging.js'Params:
| Name | Type | Attribute | Description |
| name | * |
Return:
| {"log": *, "info": *, "warn": *, "error": *, "trace": *} |
public createStore(displayName: *, objectPattern1: {"alt": *, "state": *, "calls": *, "sources": *, "viewActions": *}): * source
import createStore from '@xailabs/altx/src/createStore.js'Params:
| Name | Type | Attribute | Description |
| displayName | * | ||
| objectPattern1 | {"alt": *, "state": *, "calls": *, "sources": *, "viewActions": *} |
|
Return:
| * |
public creatorConstraints() source
import {creatorConstraints} from '@xailabs/altx/src/utils/validate/validateCreator.js'public definitionConstraints() source
import {definitionConstraints} from '@xailabs/altx/src/utils/validate/validateDefinition.js'public flatten(args: ...*): * source
import flatten from '@xailabs/altx/src/utils/flatten.js'Reduces a mixed array to a flat one.
Params:
| Name | Type | Attribute | Description |
| args | ...* |
Return:
| * |
public getAltInstance(): * source
import {getAltInstance} from '@xailabs/altx/src/altInstance.js'Return:
| * |
public getSources(calls: *): * source
import getSources from '@xailabs/altx/src/getSources.js'Params:
| Name | Type | Attribute | Description |
| calls | * |
Return:
| * |
public handlerConstraints() source
import {handlerConstraints} from '@xailabs/altx/src/utils/validate/validateHandler.js'public handlerFactory(action: *, objectPattern1: {"namespace": *, "logger": *}): {"create": *} source
import handlerFactory from '@xailabs/altx/src/handlerFactory.js'Params:
| Name | Type | Attribute | Description |
| action | * | ||
| objectPattern1 | {"namespace": *, "logger": *} |
|
Return:
| {"create": *} |
public setAltInstance(alt: *) source
import {setAltInstance} from '@xailabs/altx/src/altInstance.js'Params:
| Name | Type | Attribute | Description |
| alt | * |
public setLevel(value: *) source
import {setLevel} from '@xailabs/altx/src/utils/logging.js'Params:
| Name | Type | Attribute | Description |
| value | * |
public validateCreator(call: *, logger: *): * source
import validateCreator from '@xailabs/altx/src/utils/validate/validateCreator.js'Params:
| Name | Type | Attribute | Description |
| call | * | ||
| logger | * |
|
Return:
| * |
public validateDefinition(definition: *, logger: *): * source
import validateDefinition from '@xailabs/altx/src/utils/validate/validateDefinition.js'Params:
| Name | Type | Attribute | Description |
| definition | * | ||
| logger | * |
|
Return:
| * |
public validateHandler(handler: *, logger: *): * source
import validateHandler from '@xailabs/altx/src/utils/validate/validateHandler.js'Params:
| Name | Type | Attribute | Description |
| handler | * | ||
| logger | * |
|
Return:
| * |