wip
@ -1,228 +0,0 @@
|
||||
[updux - v1.2.0](README.md) › [Globals](globals.md)
|
||||
|
||||
# updux - v1.2.0
|
||||
|
||||
# What's Updux?
|
||||
|
||||
So, I'm a fan of [Redux](https://redux.js.org). Two days ago I discovered
|
||||
[rematch](https://rematch.github.io/rematch) alonside a few other frameworks built atop Redux.
|
||||
|
||||
It has a couple of pretty good ideas that removes some of the
|
||||
boilerplate. Keeping mutations and asynchronous effects close to the
|
||||
reducer definition? Nice. Automatically infering the
|
||||
actions from the said mutations and effects? Genius!
|
||||
|
||||
But it also enforces a flat hierarchy of reducers -- where
|
||||
is the fun in that? And I'm also having a strong love for
|
||||
[Updeep](https://github.com/substantial/updeep), so I want reducer state updates to leverage the heck out of it.
|
||||
|
||||
All that to say, say hello to `Updux`. Heavily inspired by `rematch`, but twisted
|
||||
to work with `updeep` and to fit my peculiar needs. It offers features such as
|
||||
|
||||
* Mimic the way VueX has mutations (reducer reactions to specific actions) and
|
||||
effects (middleware reacting to actions that can be asynchronous and/or
|
||||
have side-effects), so everything pertaining to a store are all defined
|
||||
in the space place.
|
||||
* Automatically gather all actions used by the updux's effects and mutations,
|
||||
and makes then accessible as attributes to the `dispatch` object of the
|
||||
store.
|
||||
* Mutations have a signature that is friendly to Updux and Immer.
|
||||
* Also, the mutation signature auto-unwrap the payload of the actions for you.
|
||||
* TypeScript types.
|
||||
|
||||
Fair warning: this package is still very new, probably very buggy,
|
||||
definitively very badly documented, and very subject to changes. Caveat
|
||||
Maxima Emptor.
|
||||
|
||||
# Synopsis
|
||||
|
||||
```
|
||||
import updux from 'updux';
|
||||
|
||||
import otherUpdux from './otherUpdux';
|
||||
|
||||
const {
|
||||
initial,
|
||||
reducer,
|
||||
actions,
|
||||
middleware,
|
||||
createStore,
|
||||
} = new Updux({
|
||||
initial: {
|
||||
counter: 0,
|
||||
},
|
||||
subduxes: {
|
||||
otherUpdux,
|
||||
},
|
||||
mutations: {
|
||||
inc: ( increment = 1 ) => u({counter: s => s + increment })
|
||||
},
|
||||
effects: {
|
||||
'*' => api => next => action => {
|
||||
console.log( "hey, look, an action zoomed by!", action );
|
||||
next(action);
|
||||
};
|
||||
},
|
||||
actions: {
|
||||
customAction: ( someArg ) => ({
|
||||
type: "custom",
|
||||
payload: { someProp: someArg }
|
||||
}),
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
const store = createStore();
|
||||
|
||||
store.dispatch.inc(3);
|
||||
```
|
||||
|
||||
# Description
|
||||
|
||||
Full documentation can be [found here](https://yanick.github.io/updux/docs/).
|
||||
|
||||
## Exporting upduxes
|
||||
|
||||
If you are creating upduxes that will be used as subduxes
|
||||
by other upduxes, or as
|
||||
[ducks](https://github.com/erikras/ducks-modular-redux)-like containers, I
|
||||
recommend that you export the Updux instance as the default export:
|
||||
|
||||
```
|
||||
import Updux from 'updux';
|
||||
|
||||
const updux = new Updux({ ... });
|
||||
|
||||
export default updux;
|
||||
```
|
||||
|
||||
Then you can use them as subduxes like this:
|
||||
|
||||
```
|
||||
import Updux from 'updux';
|
||||
import foo from './foo'; // foo is an Updux
|
||||
import bar from './bar'; // bar is an Updux as well
|
||||
|
||||
const updux = new Updux({
|
||||
subduxes: {
|
||||
foo, bar
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Or if you want to use it:
|
||||
|
||||
```
|
||||
import updux from './myUpdux';
|
||||
|
||||
const {
|
||||
reducer,
|
||||
actions: { doTheThing },
|
||||
createStore,
|
||||
middleware,
|
||||
} = updux;
|
||||
```
|
||||
|
||||
## Mapping a mutation to all values of a state
|
||||
|
||||
Say you have a `todos` state that is an array of `todo` sub-states. It's easy
|
||||
enough to have the main reducer maps away all items to the sub-reducer:
|
||||
|
||||
```
|
||||
const todo = new Updux({
|
||||
mutations: {
|
||||
review: () => u({ reviewed: true}),
|
||||
done: () => u({done: true}),
|
||||
},
|
||||
});
|
||||
|
||||
const todos = new Updux({ initial: [] });
|
||||
|
||||
todos.addMutation(
|
||||
todo.actions.review,
|
||||
(_,action) => state => state.map( todo.upreducer(action) )
|
||||
);
|
||||
todos.addMutation(
|
||||
todo.actions.done,
|
||||
(id,action) => u.map(u.if(u.is('id',id), todo.upreducer(action))),
|
||||
);
|
||||
|
||||
```
|
||||
|
||||
But `updeep` can iterate through all the items of an array (or the values of
|
||||
an object) via the special key `*`. So the todos updux above could also be
|
||||
written:
|
||||
|
||||
```
|
||||
const todo = new Updux({
|
||||
mutations: {
|
||||
review: () => u({ reviewed: true}),
|
||||
done: () => u({done: true}),
|
||||
},
|
||||
});
|
||||
|
||||
const todos = new Updux({
|
||||
subduxes: { '*': todo },
|
||||
});
|
||||
|
||||
todos.addMutation(
|
||||
todo.actions.done,
|
||||
(id,action) => u.map(u.if(u.is('id',id), todo.upreducer(action))),
|
||||
true
|
||||
);
|
||||
```
|
||||
|
||||
The advantages being that the actions/mutations/effects of the subdux will be
|
||||
imported by the root updux as usual, and all actions that aren't being
|
||||
overridden by a sink mutation will trickle down automatically.
|
||||
|
||||
## Usage with Immer
|
||||
|
||||
While Updux was created with Updeep in mind, it also plays very
|
||||
well with [Immer](https://immerjs.github.io/immer/docs/introduction).
|
||||
|
||||
For example, taking this basic updux:
|
||||
|
||||
```
|
||||
import Updux from 'updux';
|
||||
|
||||
const updux = new Updux({
|
||||
initial: { counter: 0 },
|
||||
mutations: {
|
||||
add: (inc=1) => state => { counter: counter + inc }
|
||||
}
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
Converting it to Immer would look like:
|
||||
|
||||
```
|
||||
import Updux from 'updux';
|
||||
import { produce } from 'Immer';
|
||||
|
||||
const updux = new Updux({
|
||||
initial: { counter: 0 },
|
||||
mutations: {
|
||||
add: (inc=1) => produce( draft => draft.counter += inc ) }
|
||||
}
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
But since typing `produce` over and over is no fun, `groomMutations`
|
||||
can be used to wrap all mutations with it:
|
||||
|
||||
```
|
||||
import Updux from 'updux';
|
||||
import { produce } from 'Immer';
|
||||
|
||||
const updux = new Updux({
|
||||
initial: { counter: 0 },
|
||||
groomMutations: mutation => (...args) => produce( mutation(...args) ),
|
||||
mutations: {
|
||||
add: (inc=1) => draft => draft.counter += inc
|
||||
}
|
||||
});
|
||||
|
||||
```
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 9.4 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
1
docs/API/assets/search.js
Normal file
@ -0,0 +1 @@
|
||||
window.searchData = {"kinds":{"4":"Namespace","128":"Class","256":"Interface","512":"Constructor","1024":"Property","262144":"Accessor","4194304":"Type alias"},"rows":[{"id":0,"kind":4194304,"name":"Dict","url":"modules.html#Dict","classes":"tsd-kind-type-alias tsd-has-type-parameter"},{"id":1,"kind":4,"name":"\"updux\"","url":"modules/_updux_.html","classes":"tsd-kind-namespace"},{"id":2,"kind":256,"name":"UpduxConfig","url":"interfaces/_updux_.UpduxConfig.html","classes":"tsd-kind-interface tsd-parent-kind-namespace tsd-has-type-parameter","parent":"\"updux\""},{"id":3,"kind":1024,"name":"initial","url":"interfaces/_updux_.UpduxConfig.html#initial","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"updux\".UpduxConfig"},{"id":4,"kind":1024,"name":"subduxes","url":"interfaces/_updux_.UpduxConfig.html#subduxes","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"updux\".UpduxConfig"},{"id":5,"kind":1024,"name":"actions","url":"interfaces/_updux_.UpduxConfig.html#actions","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"updux\".UpduxConfig"},{"id":6,"kind":1024,"name":"selectors","url":"interfaces/_updux_.UpduxConfig.html#selectors","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"updux\".UpduxConfig"},{"id":7,"kind":1024,"name":"mutations","url":"interfaces/_updux_.UpduxConfig.html#mutations","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"updux\".UpduxConfig"},{"id":8,"kind":1024,"name":"mappedSelectors","url":"interfaces/_updux_.UpduxConfig.html#mappedSelectors","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"updux\".UpduxConfig"},{"id":9,"kind":1024,"name":"effects","url":"interfaces/_updux_.UpduxConfig.html#effects","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"updux\".UpduxConfig"},{"id":10,"kind":1024,"name":"reactions","url":"interfaces/_updux_.UpduxConfig.html#reactions","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"updux\".UpduxConfig"},{"id":11,"kind":1024,"name":"mappedReaction","url":"interfaces/_updux_.UpduxConfig.html#mappedReaction","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"updux\".UpduxConfig"},{"id":12,"kind":128,"name":"Updux","url":"classes/_updux_.Updux.html","classes":"tsd-kind-class tsd-parent-kind-namespace tsd-has-type-parameter","parent":"\"updux\""},{"id":13,"kind":512,"name":"constructor","url":"classes/_updux_.Updux.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class tsd-has-type-parameter","parent":"\"updux\".Updux"},{"id":14,"kind":262144,"name":"initial","url":"classes/_updux_.Updux.html#initial","classes":"tsd-kind-get-signature tsd-parent-kind-class","parent":"\"updux\".Updux"},{"id":15,"kind":262144,"name":"selectors","url":"classes/_updux_.Updux.html#selectors","classes":"tsd-kind-get-signature tsd-parent-kind-class","parent":"\"updux\".Updux"}],"index":{"version":"2.3.9","fields":["name","parent"],"fieldVectors":[["name/0",[0,24.277]],["parent/0",[]],["name/1",[1,13.291]],["parent/1",[]],["name/2",[2,24.277]],["parent/2",[1,1.256]],["name/3",[3,19.169]],["parent/3",[4,0.55]],["name/4",[5,24.277]],["parent/4",[4,0.55]],["name/5",[6,24.277]],["parent/5",[4,0.55]],["name/6",[7,19.169]],["parent/6",[4,0.55]],["name/7",[8,24.277]],["parent/7",[4,0.55]],["name/8",[9,24.277]],["parent/8",[4,0.55]],["name/9",[10,24.277]],["parent/9",[4,0.55]],["name/10",[11,24.277]],["parent/10",[4,0.55]],["name/11",[12,24.277]],["parent/11",[4,0.55]],["name/12",[1,13.291]],["parent/12",[1,1.256]],["name/13",[13,24.277]],["parent/13",[14,1.493]],["name/14",[3,19.169]],["parent/14",[14,1.493]],["name/15",[7,19.169]],["parent/15",[14,1.493]]],"invertedIndex":[["actions",{"_index":6,"name":{"5":{}},"parent":{}}],["constructor",{"_index":13,"name":{"13":{}},"parent":{}}],["dict",{"_index":0,"name":{"0":{}},"parent":{}}],["effects",{"_index":10,"name":{"9":{}},"parent":{}}],["initial",{"_index":3,"name":{"3":{},"14":{}},"parent":{}}],["mappedreaction",{"_index":12,"name":{"11":{}},"parent":{}}],["mappedselectors",{"_index":9,"name":{"8":{}},"parent":{}}],["mutations",{"_index":8,"name":{"7":{}},"parent":{}}],["reactions",{"_index":11,"name":{"10":{}},"parent":{}}],["selectors",{"_index":7,"name":{"6":{},"15":{}},"parent":{}}],["subduxes",{"_index":5,"name":{"4":{}},"parent":{}}],["updux",{"_index":1,"name":{"1":{},"12":{}},"parent":{"2":{},"12":{}}}],["updux\".updux",{"_index":14,"name":{},"parent":{"13":{},"14":{},"15":{}}}],["updux\".upduxconfig",{"_index":4,"name":{},"parent":{"3":{},"4":{},"5":{},"6":{},"7":{},"8":{},"9":{},"10":{},"11":{}}}],["upduxconfig",{"_index":2,"name":{"2":{}},"parent":{}}]],"pipeline":[]}}
|
Before Width: | Height: | Size: 480 B After Width: | Height: | Size: 480 B |
Before Width: | Height: | Size: 855 B After Width: | Height: | Size: 855 B |
1
docs/API/classes/_updux_.Updux.html
Normal file
@ -1,491 +0,0 @@
|
||||
[updux - v1.2.0](../README.md) › [Globals](../globals.md) › [Updux](updux.md)
|
||||
|
||||
# Class: Updux <**S, A, X, C**>
|
||||
|
||||
## Type parameters
|
||||
|
||||
▪ **S**
|
||||
|
||||
▪ **A**
|
||||
|
||||
▪ **X**
|
||||
|
||||
▪ **C**: *[UpduxConfig](../globals.md#upduxconfig)*
|
||||
|
||||
## Hierarchy
|
||||
|
||||
* **Updux**
|
||||
|
||||
## Index
|
||||
|
||||
### Constructors
|
||||
|
||||
* [constructor](updux.md#constructor)
|
||||
|
||||
### Properties
|
||||
|
||||
* [coduxes](updux.md#coduxes)
|
||||
* [groomMutations](updux.md#groommutations)
|
||||
* [subduxes](updux.md#subduxes)
|
||||
|
||||
### Accessors
|
||||
|
||||
* [_middlewareEntries](updux.md#_middlewareentries)
|
||||
* [actions](updux.md#actions)
|
||||
* [asDux](updux.md#asdux)
|
||||
* [createStore](updux.md#createstore)
|
||||
* [initial](updux.md#initial)
|
||||
* [middleware](updux.md#middleware)
|
||||
* [mutations](updux.md#mutations)
|
||||
* [reducer](updux.md#reducer)
|
||||
* [selectors](updux.md#selectors)
|
||||
* [subduxUpreducer](updux.md#subduxupreducer)
|
||||
* [upreducer](updux.md#upreducer)
|
||||
|
||||
### Methods
|
||||
|
||||
* [addAction](updux.md#addaction)
|
||||
* [addEffect](updux.md#addeffect)
|
||||
* [addMutation](updux.md#addmutation)
|
||||
* [addSelector](updux.md#addselector)
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
\+ **new Updux**(`config`: C): *[Updux](updux.md)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type | Default | Description |
|
||||
------ | ------ | ------ | ------ |
|
||||
`config` | C | {} as C | an [UpduxConfig](../globals.md#upduxconfig) plain object |
|
||||
|
||||
**Returns:** *[Updux](updux.md)*
|
||||
|
||||
## Properties
|
||||
|
||||
### coduxes
|
||||
|
||||
• **coduxes**: *[Dux](../globals.md#dux)[]*
|
||||
|
||||
___
|
||||
|
||||
### groomMutations
|
||||
|
||||
• **groomMutations**: *function*
|
||||
|
||||
#### Type declaration:
|
||||
|
||||
▸ (`mutation`: [Mutation](../globals.md#mutation)‹S›): *[Mutation](../globals.md#mutation)‹S›*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`mutation` | [Mutation](../globals.md#mutation)‹S› |
|
||||
|
||||
___
|
||||
|
||||
### subduxes
|
||||
|
||||
• **subduxes**: *[Dictionary](../globals.md#dictionary)‹[Dux](../globals.md#dux)›*
|
||||
|
||||
## Accessors
|
||||
|
||||
### _middlewareEntries
|
||||
|
||||
• **get _middlewareEntries**(): *any[]*
|
||||
|
||||
**Returns:** *any[]*
|
||||
|
||||
___
|
||||
|
||||
### actions
|
||||
|
||||
• **get actions**(): *[DuxActions](../globals.md#duxactions)‹A, C›*
|
||||
|
||||
Action creators for all actions defined or used in the actions, mutations, effects and subduxes
|
||||
of the updux config.
|
||||
|
||||
Non-custom action creators defined in `actions` have the signature `(payload={},meta={}) => ({type,
|
||||
payload,meta})` (with the extra sugar that if `meta` or `payload` are not
|
||||
specified, that key won't be present in the produced action).
|
||||
|
||||
The same action creator can be included
|
||||
in multiple subduxes. However, if two different creators
|
||||
are included for the same action, an error will be thrown.
|
||||
|
||||
**`example`**
|
||||
|
||||
```
|
||||
const actions = updux.actions;
|
||||
```
|
||||
|
||||
**Returns:** *[DuxActions](../globals.md#duxactions)‹A, C›*
|
||||
|
||||
___
|
||||
|
||||
### asDux
|
||||
|
||||
• **get asDux**(): *object*
|
||||
|
||||
Returns a <a href="https://github.com/erikras/ducks-modular-redux">ducks</a>-like
|
||||
plain object holding the reducer from the Updux object and all
|
||||
its trimmings.
|
||||
|
||||
**`example`**
|
||||
|
||||
```
|
||||
const {
|
||||
createStore,
|
||||
upreducer,
|
||||
subduxes,
|
||||
coduxes,
|
||||
middleware,
|
||||
actions,
|
||||
reducer,
|
||||
mutations,
|
||||
initial,
|
||||
selectors,
|
||||
} = myUpdux.asDux;
|
||||
```
|
||||
|
||||
**Returns:** *object*
|
||||
|
||||
* **actions**: = this.actions
|
||||
|
||||
* **coduxes**: *object[]* = this.coduxes
|
||||
|
||||
* **createStore**(): *function*
|
||||
|
||||
* (`initial?`: S, `injectEnhancer?`: Function): *Store‹S› & object*
|
||||
|
||||
* **initial**: = this.initial
|
||||
|
||||
* **middleware**(): *function*
|
||||
|
||||
* (`api`: UpduxMiddlewareAPI‹S, X›): *function*
|
||||
|
||||
* (`next`: Function): *function*
|
||||
|
||||
* (`action`: A): *any*
|
||||
|
||||
* **mutations**(): *object*
|
||||
|
||||
* **reducer**(): *function*
|
||||
|
||||
* (`state`: S | undefined, `action`: [Action](../globals.md#action)): *S*
|
||||
|
||||
* **selectors**: = this.selectors
|
||||
|
||||
* **subduxes**(): *object*
|
||||
|
||||
* **upreducer**(): *function*
|
||||
|
||||
* (`action`: [Action](../globals.md#action)): *function*
|
||||
|
||||
* (`state`: S): *S*
|
||||
|
||||
___
|
||||
|
||||
### createStore
|
||||
|
||||
• **get createStore**(): *function*
|
||||
|
||||
Returns a `createStore` function that takes two argument:
|
||||
`initial` and `injectEnhancer`. `initial` is a custom
|
||||
initial state for the store, and `injectEnhancer` is a function
|
||||
taking in the middleware built by the updux object and allowing
|
||||
you to wrap it in any enhancer you want.
|
||||
|
||||
**`example`**
|
||||
|
||||
```
|
||||
const createStore = updux.createStore;
|
||||
|
||||
const store = createStore(initial);
|
||||
```
|
||||
|
||||
**Returns:** *function*
|
||||
|
||||
▸ (`initial?`: S, `injectEnhancer?`: Function): *Store‹S› & object*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`initial?` | S |
|
||||
`injectEnhancer?` | Function |
|
||||
|
||||
___
|
||||
|
||||
### initial
|
||||
|
||||
• **get initial**(): *AggDuxState‹S, C›*
|
||||
|
||||
**Returns:** *AggDuxState‹S, C›*
|
||||
|
||||
___
|
||||
|
||||
### middleware
|
||||
|
||||
• **get middleware**(): *[UpduxMiddleware](../globals.md#upduxmiddleware)‹AggDuxState‹S, C›, [DuxSelectors](../globals.md#duxselectors)‹AggDuxState‹S, C›, X, C››*
|
||||
|
||||
Array of middlewares aggregating all the effects defined in the
|
||||
updux and its subduxes. Effects of the updux itself are
|
||||
done before the subduxes effects.
|
||||
Note that `getState` will always return the state of the
|
||||
local updux.
|
||||
|
||||
**`example`**
|
||||
|
||||
```
|
||||
const middleware = updux.middleware;
|
||||
```
|
||||
|
||||
**Returns:** *[UpduxMiddleware](../globals.md#upduxmiddleware)‹AggDuxState‹S, C›, [DuxSelectors](../globals.md#duxselectors)‹AggDuxState‹S, C›, X, C››*
|
||||
|
||||
___
|
||||
|
||||
### mutations
|
||||
|
||||
• **get mutations**(): *[Dictionary](../globals.md#dictionary)‹[Mutation](../globals.md#mutation)‹S››*
|
||||
|
||||
Merge of the updux and subduxes mutations. If an action triggers
|
||||
mutations in both the main updux and its subduxes, the subduxes
|
||||
mutations will be performed first.
|
||||
|
||||
**Returns:** *[Dictionary](../globals.md#dictionary)‹[Mutation](../globals.md#mutation)‹S››*
|
||||
|
||||
___
|
||||
|
||||
### reducer
|
||||
|
||||
• **get reducer**(): *function*
|
||||
|
||||
A Redux reducer generated using the computed initial state and
|
||||
mutations.
|
||||
|
||||
**Returns:** *function*
|
||||
|
||||
▸ (`state`: S | undefined, `action`: [Action](../globals.md#action)): *S*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`state` | S | undefined |
|
||||
`action` | [Action](../globals.md#action) |
|
||||
|
||||
___
|
||||
|
||||
### selectors
|
||||
|
||||
• **get selectors**(): *[DuxSelectors](../globals.md#duxselectors)‹AggDuxState‹S, C›, X, C›*
|
||||
|
||||
A dictionary of the updux's selectors. Subduxes'
|
||||
selectors are included as well (with the mapping to the
|
||||
sub-state already taken care of you).
|
||||
|
||||
**Returns:** *[DuxSelectors](../globals.md#duxselectors)‹AggDuxState‹S, C›, X, C›*
|
||||
|
||||
___
|
||||
|
||||
### subduxUpreducer
|
||||
|
||||
• **get subduxUpreducer**(): *function*
|
||||
|
||||
Returns the upreducer made of the merge of all sudbuxes reducers, without
|
||||
the local mutations. Useful, for example, for sink mutations.
|
||||
|
||||
**`example`**
|
||||
|
||||
```
|
||||
import todo from './todo'; // updux for a single todo
|
||||
import Updux from 'updux';
|
||||
import u from 'updeep';
|
||||
|
||||
const todos = new Updux({ initial: [], subduxes: { '*': todo } });
|
||||
todos.addMutation(
|
||||
todo.actions.done,
|
||||
({todo_id},action) => u.map( u.if( u.is('id',todo_id) ), todos.subduxUpreducer(action) )
|
||||
true
|
||||
);
|
||||
```
|
||||
|
||||
**Returns:** *function*
|
||||
|
||||
▸ (`action`: [Action](../globals.md#action)): *function*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`action` | [Action](../globals.md#action) |
|
||||
|
||||
▸ (`state`: S): *S*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`state` | S |
|
||||
|
||||
___
|
||||
|
||||
### upreducer
|
||||
|
||||
• **get upreducer**(): *[Upreducer](../globals.md#upreducer)‹S›*
|
||||
|
||||
**Returns:** *[Upreducer](../globals.md#upreducer)‹S›*
|
||||
|
||||
## Methods
|
||||
|
||||
### addAction
|
||||
|
||||
▸ **addAction**(`theaction`: string, `transform?`: any): *ActionCreator‹string, any›*
|
||||
|
||||
Adds an action to the updux. It can take an already defined action
|
||||
creator, or any arguments that can be passed to `actionCreator`.
|
||||
|
||||
**`example`**
|
||||
```
|
||||
const action = updux.addAction( name, ...creatorArgs );
|
||||
const action = updux.addAction( otherActionCreator );
|
||||
```
|
||||
|
||||
**`example`**
|
||||
```
|
||||
import {actionCreator, Updux} from 'updux';
|
||||
|
||||
const updux = new Updux();
|
||||
|
||||
const foo = updux.addAction('foo');
|
||||
const bar = updux.addAction( 'bar', (x) => ({stuff: x+1}) );
|
||||
|
||||
const baz = actionCreator( 'baz' );
|
||||
|
||||
foo({ a: 1}); // => { type: 'foo', payload: { a: 1 } }
|
||||
bar(2); // => { type: 'bar', payload: { stuff: 3 } }
|
||||
baz(); // => { type: 'baz', payload: undefined }
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`theaction` | string |
|
||||
`transform?` | any |
|
||||
|
||||
**Returns:** *ActionCreator‹string, any›*
|
||||
|
||||
▸ **addAction**(`theaction`: string | ActionCreator‹any›, `transform?`: undefined): *ActionCreator‹string, any›*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`theaction` | string | ActionCreator‹any› |
|
||||
`transform?` | undefined |
|
||||
|
||||
**Returns:** *ActionCreator‹string, any›*
|
||||
|
||||
___
|
||||
|
||||
### addEffect
|
||||
|
||||
▸ **addEffect**<**AC**>(`creator`: AC, `middleware`: [UpduxMiddleware](../globals.md#upduxmiddleware)‹AggDuxState‹S, C›, [DuxSelectors](../globals.md#duxselectors)‹AggDuxState‹S, C›, X, C›, ReturnType‹AC››, `isGenerator?`: undefined | false | true): *any*
|
||||
|
||||
**Type parameters:**
|
||||
|
||||
▪ **AC**: *ActionCreator*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`creator` | AC |
|
||||
`middleware` | [UpduxMiddleware](../globals.md#upduxmiddleware)‹AggDuxState‹S, C›, [DuxSelectors](../globals.md#duxselectors)‹AggDuxState‹S, C›, X, C›, ReturnType‹AC›› |
|
||||
`isGenerator?` | undefined | false | true |
|
||||
|
||||
**Returns:** *any*
|
||||
|
||||
▸ **addEffect**(`creator`: string, `middleware`: [UpduxMiddleware](../globals.md#upduxmiddleware)‹AggDuxState‹S, C›, [DuxSelectors](../globals.md#duxselectors)‹AggDuxState‹S, C›, X, C››, `isGenerator?`: undefined | false | true): *any*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`creator` | string |
|
||||
`middleware` | [UpduxMiddleware](../globals.md#upduxmiddleware)‹AggDuxState‹S, C›, [DuxSelectors](../globals.md#duxselectors)‹AggDuxState‹S, C›, X, C›› |
|
||||
`isGenerator?` | undefined | false | true |
|
||||
|
||||
**Returns:** *any*
|
||||
|
||||
___
|
||||
|
||||
### addMutation
|
||||
|
||||
▸ **addMutation**<**A**>(`creator`: A, `mutation`: [Mutation](../globals.md#mutation)‹S, ActionType‹A››, `isSink?`: undefined | false | true): *any*
|
||||
|
||||
Adds a mutation and its associated action to the updux.
|
||||
|
||||
**`remarks`**
|
||||
|
||||
If a local mutation was already associated to the action,
|
||||
it will be replaced by the new one.
|
||||
|
||||
**`example`**
|
||||
|
||||
```js
|
||||
updux.addMutation(
|
||||
action('ADD', payload<int>() ),
|
||||
inc => state => state + in
|
||||
);
|
||||
```
|
||||
|
||||
**Type parameters:**
|
||||
|
||||
▪ **A**: *ActionCreator*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type | Description |
|
||||
------ | ------ | ------ |
|
||||
`creator` | A | - |
|
||||
`mutation` | [Mutation](../globals.md#mutation)‹S, ActionType‹A›› | - |
|
||||
`isSink?` | undefined | false | true | If `true`, disables the subduxes mutations for this action. To conditionally run the subduxes mutations, check out [subduxUpreducer](updux.md#subduxupreducer). Defaults to `false`. |
|
||||
|
||||
**Returns:** *any*
|
||||
|
||||
▸ **addMutation**<**A**>(`creator`: string, `mutation`: [Mutation](../globals.md#mutation)‹S, any›, `isSink?`: undefined | false | true): *any*
|
||||
|
||||
**Type parameters:**
|
||||
|
||||
▪ **A**: *ActionCreator*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`creator` | string |
|
||||
`mutation` | [Mutation](../globals.md#mutation)‹S, any› |
|
||||
`isSink?` | undefined | false | true |
|
||||
|
||||
**Returns:** *any*
|
||||
|
||||
___
|
||||
|
||||
### addSelector
|
||||
|
||||
▸ **addSelector**(`name`: string, `selector`: [Selector](../globals.md#selector)): *void*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`name` | string |
|
||||
`selector` | [Selector](../globals.md#selector) |
|
||||
|
||||
**Returns:** *void*
|
@ -1,980 +0,0 @@
|
||||
[updux - v1.2.0](README.md) › [Globals](globals.md)
|
||||
|
||||
# updux - v1.2.0
|
||||
|
||||
## Index
|
||||
|
||||
### Classes
|
||||
|
||||
* [Updux](classes/updux.md)
|
||||
|
||||
### Type aliases
|
||||
|
||||
* [Action](globals.md#action)
|
||||
* [ActionPair](globals.md#actionpair)
|
||||
* [ActionPayloadGenerator](globals.md#actionpayloadgenerator)
|
||||
* [ActionsOf](globals.md#actionsof)
|
||||
* [CoduxesOf](globals.md#coduxesof)
|
||||
* [Dictionary](globals.md#dictionary)
|
||||
* [Dux](globals.md#dux)
|
||||
* [DuxActions](globals.md#duxactions)
|
||||
* [DuxActionsCoduxes](globals.md#duxactionscoduxes)
|
||||
* [DuxActionsSubduxes](globals.md#duxactionssubduxes)
|
||||
* [DuxSelectors](globals.md#duxselectors)
|
||||
* [DuxState](globals.md#duxstate)
|
||||
* [DuxStateCoduxes](globals.md#duxstatecoduxes)
|
||||
* [DuxStateGlobSub](globals.md#duxstateglobsub)
|
||||
* [DuxStateSubduxes](globals.md#duxstatesubduxes)
|
||||
* [Effect](globals.md#effect)
|
||||
* [GenericActions](globals.md#genericactions)
|
||||
* [ItemsOf](globals.md#itemsof)
|
||||
* [LocalDuxState](globals.md#localduxstate)
|
||||
* [MaybePayload](globals.md#maybepayload)
|
||||
* [MaybeReturnType](globals.md#maybereturntype)
|
||||
* [Merge](globals.md#merge)
|
||||
* [Mutation](globals.md#mutation)
|
||||
* [MutationEntry](globals.md#mutationentry)
|
||||
* [MwGen](globals.md#mwgen)
|
||||
* [Next](globals.md#next)
|
||||
* [RebaseSelector](globals.md#rebaseselector)
|
||||
* [Selector](globals.md#selector)
|
||||
* [SelectorsOf](globals.md#selectorsof)
|
||||
* [StateOf](globals.md#stateof)
|
||||
* [StoreWithDispatchActions](globals.md#storewithdispatchactions)
|
||||
* [SubMutations](globals.md#submutations)
|
||||
* [Submws](globals.md#submws)
|
||||
* [UnionToIntersection](globals.md#uniontointersection)
|
||||
* [UpduxActions](globals.md#upduxactions)
|
||||
* [UpduxConfig](globals.md#upduxconfig)
|
||||
* [UpduxLocalActions](globals.md#upduxlocalactions)
|
||||
* [UpduxMiddleware](globals.md#upduxmiddleware)
|
||||
* [Upreducer](globals.md#upreducer)
|
||||
|
||||
### Variables
|
||||
|
||||
* [subEffects](globals.md#const-subeffects)
|
||||
* [updux](globals.md#const-updux)
|
||||
|
||||
### Functions
|
||||
|
||||
* [MiddlewareFor](globals.md#const-middlewarefor)
|
||||
* [buildActions](globals.md#buildactions)
|
||||
* [buildCreateStore](globals.md#buildcreatestore)
|
||||
* [buildInitial](globals.md#buildinitial)
|
||||
* [buildMiddleware](globals.md#buildmiddleware)
|
||||
* [buildMutations](globals.md#buildmutations)
|
||||
* [buildSelectors](globals.md#buildselectors)
|
||||
* [buildUpreducer](globals.md#buildupreducer)
|
||||
* [coduxes](globals.md#const-coduxes)
|
||||
* [composeMutations](globals.md#const-composemutations)
|
||||
* [composeMw](globals.md#const-composemw)
|
||||
* [dux](globals.md#const-dux)
|
||||
* [effectToMw](globals.md#const-effecttomw)
|
||||
* [sliceMw](globals.md#slicemw)
|
||||
* [subMiddleware](globals.md#const-submiddleware)
|
||||
* [subSelectors](globals.md#subselectors)
|
||||
|
||||
## Type aliases
|
||||
|
||||
### Action
|
||||
|
||||
Ƭ **Action**: *object & [MaybePayload](globals.md#maybepayload)‹P›*
|
||||
|
||||
___
|
||||
|
||||
### ActionPair
|
||||
|
||||
Ƭ **ActionPair**: *[string, ActionCreator]*
|
||||
|
||||
___
|
||||
|
||||
### ActionPayloadGenerator
|
||||
|
||||
Ƭ **ActionPayloadGenerator**: *function*
|
||||
|
||||
#### Type declaration:
|
||||
|
||||
▸ (...`args`: any[]): *any*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`...args` | any[] |
|
||||
|
||||
___
|
||||
|
||||
### ActionsOf
|
||||
|
||||
Ƭ **ActionsOf**: *U extends Updux ? U["actions"] : object*
|
||||
|
||||
___
|
||||
|
||||
### CoduxesOf
|
||||
|
||||
Ƭ **CoduxesOf**: *U extends Updux<any, any, any, infer S> ? S : []*
|
||||
|
||||
___
|
||||
|
||||
### Dictionary
|
||||
|
||||
Ƭ **Dictionary**: *object*
|
||||
|
||||
#### Type declaration:
|
||||
|
||||
* \[ **key**: *string*\]: T
|
||||
|
||||
___
|
||||
|
||||
### Dux
|
||||
|
||||
Ƭ **Dux**: *object*
|
||||
|
||||
#### Type declaration:
|
||||
|
||||
* **actions**: *A*
|
||||
|
||||
* **coduxes**: *[Dux](globals.md#dux)[]*
|
||||
|
||||
* **initial**: *AggDuxState‹S, C›*
|
||||
|
||||
* **subduxes**: *[Dictionary](globals.md#dictionary)‹[Dux](globals.md#dux)›*
|
||||
|
||||
___
|
||||
|
||||
### DuxActions
|
||||
|
||||
Ƭ **DuxActions**:
|
||||
|
||||
___
|
||||
|
||||
### DuxActionsCoduxes
|
||||
|
||||
Ƭ **DuxActionsCoduxes**: *C extends Array<infer I> ? UnionToIntersection<ActionsOf<I>> : object*
|
||||
|
||||
___
|
||||
|
||||
### DuxActionsSubduxes
|
||||
|
||||
Ƭ **DuxActionsSubduxes**: *C extends object ? ActionsOf<C[keyof C]> : unknown*
|
||||
|
||||
___
|
||||
|
||||
### DuxSelectors
|
||||
|
||||
Ƭ **DuxSelectors**: *unknown extends X ? object : X*
|
||||
|
||||
___
|
||||
|
||||
### DuxState
|
||||
|
||||
Ƭ **DuxState**: *D extends object ? S : unknown*
|
||||
|
||||
___
|
||||
|
||||
### DuxStateCoduxes
|
||||
|
||||
Ƭ **DuxStateCoduxes**: *C extends Array<infer U> ? UnionToIntersection<StateOf<U>> : unknown*
|
||||
|
||||
___
|
||||
|
||||
### DuxStateGlobSub
|
||||
|
||||
Ƭ **DuxStateGlobSub**: *S extends object ? StateOf<I> : unknown*
|
||||
|
||||
___
|
||||
|
||||
### DuxStateSubduxes
|
||||
|
||||
Ƭ **DuxStateSubduxes**: *C extends object ? object : C extends object ? object : unknown*
|
||||
|
||||
___
|
||||
|
||||
### Effect
|
||||
|
||||
Ƭ **Effect**: *[string, [UpduxMiddleware](globals.md#upduxmiddleware) | [MwGen](globals.md#mwgen), undefined | false | true]*
|
||||
|
||||
___
|
||||
|
||||
### GenericActions
|
||||
|
||||
Ƭ **GenericActions**: *[Dictionary](globals.md#dictionary)‹ActionCreator‹string, function››*
|
||||
|
||||
___
|
||||
|
||||
### ItemsOf
|
||||
|
||||
Ƭ **ItemsOf**: *C extends object ? C[keyof C] : unknown*
|
||||
|
||||
___
|
||||
|
||||
### LocalDuxState
|
||||
|
||||
Ƭ **LocalDuxState**: *S extends never[] ? unknown[] : S*
|
||||
|
||||
___
|
||||
|
||||
### MaybePayload
|
||||
|
||||
Ƭ **MaybePayload**: *P extends object | string | boolean | number ? object : object*
|
||||
|
||||
___
|
||||
|
||||
### MaybeReturnType
|
||||
|
||||
Ƭ **MaybeReturnType**: *X extends function ? ReturnType<X> : unknown*
|
||||
|
||||
___
|
||||
|
||||
### Merge
|
||||
|
||||
Ƭ **Merge**: *[UnionToIntersection](globals.md#uniontointersection)‹T[keyof T]›*
|
||||
|
||||
___
|
||||
|
||||
### Mutation
|
||||
|
||||
Ƭ **Mutation**: *function*
|
||||
|
||||
#### Type declaration:
|
||||
|
||||
▸ (`payload`: A["payload"], `action`: A): *function*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`payload` | A["payload"] |
|
||||
`action` | A |
|
||||
|
||||
▸ (`state`: S): *S*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`state` | S |
|
||||
|
||||
___
|
||||
|
||||
### MutationEntry
|
||||
|
||||
Ƭ **MutationEntry**: *[ActionCreator | string, [Mutation](globals.md#mutation)‹any, [Action](globals.md#action)‹string, any››, undefined | false | true]*
|
||||
|
||||
___
|
||||
|
||||
### MwGen
|
||||
|
||||
Ƭ **MwGen**: *function*
|
||||
|
||||
#### Type declaration:
|
||||
|
||||
▸ (): *[UpduxMiddleware](globals.md#upduxmiddleware)*
|
||||
|
||||
___
|
||||
|
||||
### Next
|
||||
|
||||
Ƭ **Next**: *function*
|
||||
|
||||
#### Type declaration:
|
||||
|
||||
▸ (`action`: [Action](globals.md#action)): *any*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`action` | [Action](globals.md#action) |
|
||||
|
||||
___
|
||||
|
||||
### RebaseSelector
|
||||
|
||||
Ƭ **RebaseSelector**: *object*
|
||||
|
||||
#### Type declaration:
|
||||
|
||||
___
|
||||
|
||||
### Selector
|
||||
|
||||
Ƭ **Selector**: *function*
|
||||
|
||||
#### Type declaration:
|
||||
|
||||
▸ (`state`: S): *unknown*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`state` | S |
|
||||
|
||||
___
|
||||
|
||||
### SelectorsOf
|
||||
|
||||
Ƭ **SelectorsOf**: *C extends object ? S : unknown*
|
||||
|
||||
___
|
||||
|
||||
### StateOf
|
||||
|
||||
Ƭ **StateOf**: *D extends object ? I : unknown*
|
||||
|
||||
___
|
||||
|
||||
### StoreWithDispatchActions
|
||||
|
||||
Ƭ **StoreWithDispatchActions**: *Store‹S› & object*
|
||||
|
||||
___
|
||||
|
||||
### SubMutations
|
||||
|
||||
Ƭ **SubMutations**: *object*
|
||||
|
||||
#### Type declaration:
|
||||
|
||||
* \[ **slice**: *string*\]: [Dictionary](globals.md#dictionary)‹[Mutation](globals.md#mutation)›
|
||||
|
||||
___
|
||||
|
||||
### Submws
|
||||
|
||||
Ƭ **Submws**: *[Dictionary](globals.md#dictionary)‹[UpduxMiddleware](globals.md#upduxmiddleware)›*
|
||||
|
||||
___
|
||||
|
||||
### UnionToIntersection
|
||||
|
||||
Ƭ **UnionToIntersection**: *U extends any ? function : never extends function ? I : never*
|
||||
|
||||
___
|
||||
|
||||
### UpduxActions
|
||||
|
||||
Ƭ **UpduxActions**: *U extends Updux ? UnionToIntersection<UpduxLocalActions<U> | ActionsOf<CoduxesOf<U>[keyof CoduxesOf<U>]>> : object*
|
||||
|
||||
___
|
||||
|
||||
### UpduxConfig
|
||||
|
||||
Ƭ **UpduxConfig**: *Partial‹object›*
|
||||
|
||||
Configuration object given to Updux's constructor.
|
||||
|
||||
#### arguments
|
||||
|
||||
##### initial
|
||||
|
||||
Default initial state of the reducer. If applicable, is merged with
|
||||
the subduxes initial states, with the parent having precedence.
|
||||
|
||||
If not provided, defaults to an empty object.
|
||||
|
||||
##### actions
|
||||
|
||||
[Actions](/concepts/Actions) used by the updux.
|
||||
|
||||
```js
|
||||
import { dux } from 'updux';
|
||||
import { action, payload } from 'ts-action';
|
||||
|
||||
const bar = action('BAR', payload<int>());
|
||||
const foo = action('FOO');
|
||||
|
||||
const myDux = dux({
|
||||
actions: {
|
||||
bar
|
||||
},
|
||||
mutations: [
|
||||
[ foo, () => state => state ]
|
||||
]
|
||||
});
|
||||
|
||||
myDux.actions.foo({ x: 1, y: 2 }); // => { type: foo, x:1, y:2 }
|
||||
myDux.actions.bar(2); // => { type: bar, payload: 2 }
|
||||
```
|
||||
|
||||
New actions used directly in mutations and effects will be added to the
|
||||
dux actions -- that is, they will be accessible via `dux.actions` -- but will
|
||||
not appear as part of its Typescript type.
|
||||
|
||||
##### selectors
|
||||
|
||||
Dictionary of selectors for the current updux. The updux also
|
||||
inherit its subduxes' selectors.
|
||||
|
||||
The selectors are available via the class' getter.
|
||||
|
||||
##### mutations
|
||||
|
||||
mutations: [
|
||||
[ action, mutation, isSink ],
|
||||
...
|
||||
]
|
||||
|
||||
or
|
||||
|
||||
mutations: {
|
||||
action: mutation,
|
||||
...
|
||||
}
|
||||
|
||||
List of mutations for assign to the dux. If you want Typescript goodness, you
|
||||
probably want to use `addMutation()` instead.
|
||||
|
||||
In its generic array-of-array form,
|
||||
each mutation tuple contains: the action, the mutation,
|
||||
and boolean indicating if this is a sink mutation.
|
||||
|
||||
The action can be an action creator function or a string. If it's a string, it's considered to be the
|
||||
action type and a generic `action( actionName, payload() )` creator will be
|
||||
generated for it. If an action is not already defined in the `actions`
|
||||
parameter, it'll be automatically added.
|
||||
|
||||
The pseudo-action type `*` can be used to match any action not explicitly matched by other mutations.
|
||||
|
||||
```js
|
||||
const todosUpdux = updux({
|
||||
mutations: {
|
||||
add: todo => state => [ ...state, todo ],
|
||||
done: done_id => u.map( u.if( ({id} => id === done_id), {done: true} ) ),
|
||||
'*' (payload,action) => state => {
|
||||
console.warn( "unexpected action ", action.type );
|
||||
return state;
|
||||
},
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
The signature of the mutations is `(payload,action) => state => newState`.
|
||||
It is designed to play well with `Updeep` (and [Immer](https://immerjs.github.io/immer/docs/introduction)). This way, instead of doing
|
||||
|
||||
```js
|
||||
mutation: {
|
||||
renameTodo: newName => state => { ...state, name: newName }
|
||||
}
|
||||
```
|
||||
|
||||
we can do
|
||||
|
||||
```js
|
||||
mutation: {
|
||||
renameTodo: newName => u({ name: newName })
|
||||
}
|
||||
```
|
||||
|
||||
The final argument is the optional boolean `isSink`. If it is true, it'll
|
||||
prevent subduxes' mutations on the same action. It defaults to `false`.
|
||||
|
||||
The object version of the argument can be used as a shortcut when all actions
|
||||
are strings. In that case, `isSink` is `false` for all mutations.
|
||||
|
||||
##### groomMutations
|
||||
|
||||
Function that can be provided to alter all local mutations of the updux
|
||||
(the mutations of subduxes are left untouched).
|
||||
|
||||
Can be used, for example, for Immer integration:
|
||||
|
||||
```js
|
||||
import Updux from 'updux';
|
||||
import { produce } from 'Immer';
|
||||
|
||||
const updux = new Updux({
|
||||
initial: { counter: 0 },
|
||||
groomMutations: mutation => (...args) => produce( mutation(...args) ),
|
||||
mutations: {
|
||||
add: (inc=1) => draft => draft.counter += inc
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Or perhaps for debugging:
|
||||
|
||||
```js
|
||||
import Updux from 'updux';
|
||||
|
||||
const updux = new Updux({
|
||||
initial: { counter: 0 },
|
||||
groomMutations: mutation => (...args) => state => {
|
||||
console.log( "got action ", args[1] );
|
||||
return mutation(...args)(state);
|
||||
}
|
||||
});
|
||||
```
|
||||
##### subduxes
|
||||
|
||||
Object mapping slices of the state to sub-upduxes. In addition to creating
|
||||
sub-reducers for those slices, it'll make the parend updux inherit all the
|
||||
actions and middleware from its subduxes.
|
||||
|
||||
For example, if in plain Redux you would do
|
||||
|
||||
```js
|
||||
import { combineReducers } from 'redux';
|
||||
import todosReducer from './todos';
|
||||
import statisticsReducer from './statistics';
|
||||
|
||||
const rootReducer = combineReducers({
|
||||
todos: todosReducer,
|
||||
stats: statisticsReducer,
|
||||
});
|
||||
```
|
||||
|
||||
then with Updux you'd do
|
||||
|
||||
```js
|
||||
import { updux } from 'updux';
|
||||
import todos from './todos';
|
||||
import statistics from './statistics';
|
||||
|
||||
const rootUpdux = updux({
|
||||
subduxes: {
|
||||
todos,
|
||||
statistics
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
##### effects
|
||||
|
||||
Array of arrays or plain object defining asynchronous actions and side-effects triggered by actions.
|
||||
The effects themselves are Redux middleware, with the `dispatch`
|
||||
property of the first argument augmented with all the available actions.
|
||||
|
||||
```
|
||||
updux({
|
||||
effects: {
|
||||
fetch: ({dispatch}) => next => async (action) => {
|
||||
next(action);
|
||||
|
||||
let result = await fetch(action.payload.url).then( result => result.json() );
|
||||
dispatch.fetchSuccess(result);
|
||||
}
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
**`example`**
|
||||
|
||||
```
|
||||
import Updux from 'updux';
|
||||
import { actions, payload } from 'ts-action';
|
||||
import u from 'updeep';
|
||||
|
||||
const todoUpdux = new Updux({
|
||||
initial: {
|
||||
done: false,
|
||||
note: "",
|
||||
},
|
||||
actions: {
|
||||
finish: action('FINISH', payload()),
|
||||
edit: action('EDIT', payload()),
|
||||
},
|
||||
mutations: [
|
||||
[ edit, note => u({note}) ]
|
||||
],
|
||||
selectors: {
|
||||
getNote: state => state.note
|
||||
},
|
||||
groomMutations: mutation => transform(mutation),
|
||||
subduxes: {
|
||||
foo
|
||||
},
|
||||
effects: {
|
||||
finish: () => next => action => {
|
||||
console.log( "Woo! one more bites the dust" );
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
___
|
||||
|
||||
### UpduxLocalActions
|
||||
|
||||
Ƭ **UpduxLocalActions**: *S extends Updux<any, null> ? object : S extends Updux<any, infer A> ? A : object*
|
||||
|
||||
___
|
||||
|
||||
### UpduxMiddleware
|
||||
|
||||
Ƭ **UpduxMiddleware**: *function*
|
||||
|
||||
#### Type declaration:
|
||||
|
||||
▸ (`api`: UpduxMiddlewareAPI‹S, X›): *function*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`api` | UpduxMiddlewareAPI‹S, X› |
|
||||
|
||||
▸ (`next`: Function): *function*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`next` | Function |
|
||||
|
||||
▸ (`action`: A): *any*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`action` | A |
|
||||
|
||||
___
|
||||
|
||||
### Upreducer
|
||||
|
||||
Ƭ **Upreducer**: *function*
|
||||
|
||||
#### Type declaration:
|
||||
|
||||
▸ (`action`: [Action](globals.md#action)): *function*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`action` | [Action](globals.md#action) |
|
||||
|
||||
▸ (`state`: S): *S*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`state` | S |
|
||||
|
||||
## Variables
|
||||
|
||||
### `Const` subEffects
|
||||
|
||||
• **subEffects**: *[Effect](globals.md#effect)* = [ '*', subMiddleware ] as any
|
||||
|
||||
___
|
||||
|
||||
### `Const` updux
|
||||
|
||||
• **updux**: *[Updux](classes/updux.md)‹unknown, null, unknown, object›* = new Updux({
|
||||
subduxes: {
|
||||
foo: dux({ initial: "banana" })
|
||||
}
|
||||
})
|
||||
|
||||
## Functions
|
||||
|
||||
### `Const` MiddlewareFor
|
||||
|
||||
▸ **MiddlewareFor**(`type`: any, `mw`: Middleware): *Middleware*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`type` | any |
|
||||
`mw` | Middleware |
|
||||
|
||||
**Returns:** *Middleware*
|
||||
|
||||
___
|
||||
|
||||
### buildActions
|
||||
|
||||
▸ **buildActions**(`actions`: [ActionPair](globals.md#actionpair)[]): *[Dictionary](globals.md#dictionary)‹ActionCreator‹string, function››*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type | Default |
|
||||
------ | ------ | ------ |
|
||||
`actions` | [ActionPair](globals.md#actionpair)[] | [] |
|
||||
|
||||
**Returns:** *[Dictionary](globals.md#dictionary)‹ActionCreator‹string, function››*
|
||||
|
||||
___
|
||||
|
||||
### buildCreateStore
|
||||
|
||||
▸ **buildCreateStore**<**S**, **A**>(`reducer`: Reducer‹S›, `middleware`: Middleware, `actions`: A): *function*
|
||||
|
||||
**Type parameters:**
|
||||
|
||||
▪ **S**
|
||||
|
||||
▪ **A**
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type | Default |
|
||||
------ | ------ | ------ |
|
||||
`reducer` | Reducer‹S› | - |
|
||||
`middleware` | Middleware | - |
|
||||
`actions` | A | {} as A |
|
||||
|
||||
**Returns:** *function*
|
||||
|
||||
▸ (`initial?`: S, `injectEnhancer?`: Function): *Store‹S› & object*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`initial?` | S |
|
||||
`injectEnhancer?` | Function |
|
||||
|
||||
___
|
||||
|
||||
### buildInitial
|
||||
|
||||
▸ **buildInitial**(`initial`: any, `coduxes`: any, `subduxes`: any): *any*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type | Default |
|
||||
------ | ------ | ------ |
|
||||
`initial` | any | - |
|
||||
`coduxes` | any | [] |
|
||||
`subduxes` | any | {} |
|
||||
|
||||
**Returns:** *any*
|
||||
|
||||
___
|
||||
|
||||
### buildMiddleware
|
||||
|
||||
▸ **buildMiddleware**<**S**>(`local`: [UpduxMiddleware](globals.md#upduxmiddleware)[], `co`: [UpduxMiddleware](globals.md#upduxmiddleware)[], `sub`: [Submws](globals.md#submws)): *[UpduxMiddleware](globals.md#upduxmiddleware)‹S›*
|
||||
|
||||
**Type parameters:**
|
||||
|
||||
▪ **S**
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type | Default |
|
||||
------ | ------ | ------ |
|
||||
`local` | [UpduxMiddleware](globals.md#upduxmiddleware)[] | [] |
|
||||
`co` | [UpduxMiddleware](globals.md#upduxmiddleware)[] | [] |
|
||||
`sub` | [Submws](globals.md#submws) | {} |
|
||||
|
||||
**Returns:** *[UpduxMiddleware](globals.md#upduxmiddleware)‹S›*
|
||||
|
||||
___
|
||||
|
||||
### buildMutations
|
||||
|
||||
▸ **buildMutations**(`mutations`: [Dictionary](globals.md#dictionary)‹[Mutation](globals.md#mutation) | [[Mutation](globals.md#mutation), boolean | undefined]›, `subduxes`: object, `coduxes`: [Upreducer](globals.md#upreducer)[]): *object*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type | Default |
|
||||
------ | ------ | ------ |
|
||||
`mutations` | [Dictionary](globals.md#dictionary)‹[Mutation](globals.md#mutation) | [[Mutation](globals.md#mutation), boolean | undefined]› | {} |
|
||||
`subduxes` | object | {} |
|
||||
`coduxes` | [Upreducer](globals.md#upreducer)[] | [] |
|
||||
|
||||
**Returns:** *object*
|
||||
|
||||
___
|
||||
|
||||
### buildSelectors
|
||||
|
||||
▸ **buildSelectors**(`localSelectors`: [Dictionary](globals.md#dictionary)‹[Selector](globals.md#selector)›, `coduxes`: [Dictionary](globals.md#dictionary)‹[Selector](globals.md#selector)›[], `subduxes`: [Dictionary](globals.md#dictionary)‹[Selector](globals.md#selector)›): *object*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type | Default |
|
||||
------ | ------ | ------ |
|
||||
`localSelectors` | [Dictionary](globals.md#dictionary)‹[Selector](globals.md#selector)› | {} |
|
||||
`coduxes` | [Dictionary](globals.md#dictionary)‹[Selector](globals.md#selector)›[] | [] |
|
||||
`subduxes` | [Dictionary](globals.md#dictionary)‹[Selector](globals.md#selector)› | {} |
|
||||
|
||||
**Returns:** *object*
|
||||
|
||||
___
|
||||
|
||||
### buildUpreducer
|
||||
|
||||
▸ **buildUpreducer**<**S**>(`initial`: S, `mutations`: [Dictionary](globals.md#dictionary)‹[Mutation](globals.md#mutation)‹S››): *[Upreducer](globals.md#upreducer)‹S›*
|
||||
|
||||
**Type parameters:**
|
||||
|
||||
▪ **S**
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`initial` | S |
|
||||
`mutations` | [Dictionary](globals.md#dictionary)‹[Mutation](globals.md#mutation)‹S›› |
|
||||
|
||||
**Returns:** *[Upreducer](globals.md#upreducer)‹S›*
|
||||
|
||||
___
|
||||
|
||||
### `Const` coduxes
|
||||
|
||||
▸ **coduxes**<**C**, **U**>(...`coduxes`: U): *object*
|
||||
|
||||
**Type parameters:**
|
||||
|
||||
▪ **C**: *[Dux](globals.md#dux)*
|
||||
|
||||
▪ **U**: *[C]*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`...coduxes` | U |
|
||||
|
||||
**Returns:** *object*
|
||||
|
||||
* **coduxes**: *U*
|
||||
|
||||
___
|
||||
|
||||
### `Const` composeMutations
|
||||
|
||||
▸ **composeMutations**(`mutations`: [Mutation](globals.md#mutation)[]): *function | (Anonymous function)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`mutations` | [Mutation](globals.md#mutation)[] |
|
||||
|
||||
**Returns:** *function | (Anonymous function)*
|
||||
|
||||
___
|
||||
|
||||
### `Const` composeMw
|
||||
|
||||
▸ **composeMw**(`mws`: [UpduxMiddleware](globals.md#upduxmiddleware)[]): *(Anonymous function)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`mws` | [UpduxMiddleware](globals.md#upduxmiddleware)[] |
|
||||
|
||||
**Returns:** *(Anonymous function)*
|
||||
|
||||
___
|
||||
|
||||
### `Const` dux
|
||||
|
||||
▸ **dux**<**S**, **A**, **X**, **C**>(`config`: C): *object*
|
||||
|
||||
**Type parameters:**
|
||||
|
||||
▪ **S**
|
||||
|
||||
▪ **A**
|
||||
|
||||
▪ **X**
|
||||
|
||||
▪ **C**: *[UpduxConfig](globals.md#upduxconfig)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`config` | C |
|
||||
|
||||
**Returns:** *object*
|
||||
|
||||
* **actions**: = this.actions
|
||||
|
||||
* **coduxes**: *object[]* = this.coduxes
|
||||
|
||||
* **createStore**(): *function*
|
||||
|
||||
* (`initial?`: S, `injectEnhancer?`: Function): *Store‹S› & object*
|
||||
|
||||
* **initial**: = this.initial
|
||||
|
||||
* **middleware**(): *function*
|
||||
|
||||
* (`api`: UpduxMiddlewareAPI‹S, X›): *function*
|
||||
|
||||
* (`next`: Function): *function*
|
||||
|
||||
* (`action`: A): *any*
|
||||
|
||||
* **mutations**(): *object*
|
||||
|
||||
* **reducer**(): *function*
|
||||
|
||||
* (`state`: S | undefined, `action`: [Action](globals.md#action)): *S*
|
||||
|
||||
* **selectors**: = this.selectors
|
||||
|
||||
* **subduxes**(): *object*
|
||||
|
||||
* **upreducer**(): *function*
|
||||
|
||||
* (`action`: [Action](globals.md#action)): *function*
|
||||
|
||||
* (`state`: S): *S*
|
||||
|
||||
___
|
||||
|
||||
### `Const` effectToMw
|
||||
|
||||
▸ **effectToMw**(`effect`: [Effect](globals.md#effect), `actions`: [Dictionary](globals.md#dictionary)‹ActionCreator›, `selectors`: [Dictionary](globals.md#dictionary)‹[Selector](globals.md#selector)›): *subMiddleware | augmented*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`effect` | [Effect](globals.md#effect) |
|
||||
`actions` | [Dictionary](globals.md#dictionary)‹ActionCreator› |
|
||||
`selectors` | [Dictionary](globals.md#dictionary)‹[Selector](globals.md#selector)› |
|
||||
|
||||
**Returns:** *subMiddleware | augmented*
|
||||
|
||||
___
|
||||
|
||||
### sliceMw
|
||||
|
||||
▸ **sliceMw**(`slice`: string, `mw`: [UpduxMiddleware](globals.md#upduxmiddleware)): *[UpduxMiddleware](globals.md#upduxmiddleware)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`slice` | string |
|
||||
`mw` | [UpduxMiddleware](globals.md#upduxmiddleware) |
|
||||
|
||||
**Returns:** *[UpduxMiddleware](globals.md#upduxmiddleware)*
|
||||
|
||||
___
|
||||
|
||||
### `Const` subMiddleware
|
||||
|
||||
▸ **subMiddleware**(): *(Anonymous function)*
|
||||
|
||||
**Returns:** *(Anonymous function)*
|
||||
|
||||
___
|
||||
|
||||
### subSelectors
|
||||
|
||||
▸ **subSelectors**(`__namedParameters`: [string, Function]): *[string, [Selector](globals.md#selector)][]*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`__namedParameters` | [string, Function] |
|
||||
|
||||
**Returns:** *[string, [Selector](globals.md#selector)][]*
|
@ -1,4 +1,4 @@
|
||||
<!DOCTYPE html><html class="default no-js"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>updux</title><meta name="description" content="Documentation for updux"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="assets/style.css"/><link rel="stylesheet" href="assets/highlight.css"/><script async src="assets/search.js" id="search-script"></script></head><body><header><div class="tsd-page-toolbar"><div class="container"><div class="table-wrap"><div class="table-cell" id="tsd-search" data-base="."><div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption">Search</label><input type="text" id="tsd-search-field"/></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="index.html" class="title">updux</a></div><div class="table-cell" id="tsd-widgets"><div id="tsd-filter"><a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a><div class="tsd-filter-group"><div class="tsd-select" id="tsd-filter-visibility"><span class="tsd-select-label">All</span><ul class="tsd-select-list"><li data-value="public">Public</li><li data-value="protected">Public/Protected</li><li data-value="private" class="selected">All</li></ul></div> <input type="checkbox" id="tsd-filter-inherited" checked/><label class="tsd-widget" for="tsd-filter-inherited">Inherited</label><input type="checkbox" id="tsd-filter-externals" checked/><label class="tsd-widget" for="tsd-filter-externals">Externals</label></div></div><a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a></div></div></div></div><div class="tsd-page-title"><div class="container"><h1> updux</h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><div class="tsd-panel tsd-typography">
|
||||
<!DOCTYPE html><html class="default no-js"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>Updux</title><meta name="description" content="Documentation for Updux"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="assets/style.css"/><link rel="stylesheet" href="assets/highlight.css"/><script async src="assets/search.js" id="search-script"></script></head><body><header><div class="tsd-page-toolbar"><div class="container"><div class="table-wrap"><div class="table-cell" id="tsd-search" data-base="."><div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption">Search</label><input type="text" id="tsd-search-field"/></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="index.html" class="title">Updux</a></div><div class="table-cell" id="tsd-widgets"><div id="tsd-filter"><a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a><div class="tsd-filter-group"><div class="tsd-select" id="tsd-filter-visibility"><span class="tsd-select-label">All</span><ul class="tsd-select-list"><li data-value="public">Public</li><li data-value="protected">Public/Protected</li><li data-value="private" class="selected">All</li></ul></div> <input type="checkbox" id="tsd-filter-inherited" checked/><label class="tsd-widget" for="tsd-filter-inherited">Inherited</label></div></div><a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a></div></div></div></div><div class="tsd-page-title"><div class="container"><h1>Updux</h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><div class="tsd-panel tsd-typography">
|
||||
<a href="#what39s-updux" id="what39s-updux" style="color: inherit; text-decoration: none;">
|
||||
<h1>What's Updux?</h1>
|
||||
</a>
|
||||
@ -89,4 +89,4 @@ well with <a href="https://immerjs.github.io/immer/docs/introduction">Immer</a>.
|
||||
can be used to wrap all mutations with it:</p>
|
||||
<pre><code><span class="hl-0">import</span><span class="hl-1"> </span><span class="hl-2">Updux</span><span class="hl-1"> </span><span class="hl-0">from</span><span class="hl-1"> </span><span class="hl-3">'updux'</span><span class="hl-1">;</span><br/><span class="hl-0">import</span><span class="hl-1"> { </span><span class="hl-2">produce</span><span class="hl-1"> } </span><span class="hl-0">from</span><span class="hl-1"> </span><span class="hl-3">'Immer'</span><span class="hl-1">;</span><br/><br/><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-5">updux</span><span class="hl-1"> = </span><span class="hl-4">new</span><span class="hl-1"> </span><span class="hl-6">Updux</span><span class="hl-1">({</span><br/><span class="hl-1"> </span><span class="hl-2">initial:</span><span class="hl-1"> { </span><span class="hl-2">counter:</span><span class="hl-1"> </span><span class="hl-7">0</span><span class="hl-1"> },</span><br/><span class="hl-1"> </span><span class="hl-6">groomMutations</span><span class="hl-2">:</span><span class="hl-1"> </span><span class="hl-2">mutation</span><span class="hl-1"> </span><span class="hl-4">=></span><span class="hl-1"> (...</span><span class="hl-2">args</span><span class="hl-1">) </span><span class="hl-4">=></span><span class="hl-1"> </span><span class="hl-6">produce</span><span class="hl-1">( </span><span class="hl-6">mutation</span><span class="hl-1">(...</span><span class="hl-2">args</span><span class="hl-1">) ),</span><br/><span class="hl-1"> </span><span class="hl-2">mutations:</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-6">add</span><span class="hl-2">:</span><span class="hl-1"> (</span><span class="hl-2">inc</span><span class="hl-1">=</span><span class="hl-7">1</span><span class="hl-1">) </span><span class="hl-4">=></span><span class="hl-1"> </span><span class="hl-2">draft</span><span class="hl-1"> </span><span class="hl-4">=></span><span class="hl-1"> </span><span class="hl-2">draft</span><span class="hl-1">.</span><span class="hl-2">counter</span><span class="hl-1"> += </span><span class="hl-2">inc</span><br/><span class="hl-1"> }</span><br/><span class="hl-1">});</span><br/>
|
||||
</code></pre>
|
||||
</div></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class="current"><a href="modules.html">Exports</a></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul></ul></nav></div></div></div><footer class="with-border-bottom"><div class="container"><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></div></footer><div class="container tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div><script src="assets/main.js"></script></body></html>
|
||||
</div></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class="current"><a href="modules.html">Exports</a></li><li class=" tsd-kind-namespace"><a href="modules/_updux_.html">"updux"</a></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul><li class="tsd-kind-type-alias tsd-has-type-parameter"><a href="modules.html#Dict" class="tsd-kind-icon">Dict</a></li></ul></nav></div></div></div><footer class="with-border-bottom"><div class="container"><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></div></footer><div class="container tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div><script src="assets/main.js"></script></body></html>
|
25
docs/API/interfaces/_updux_.UpduxConfig.html
Normal file
@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html><html class="default no-js"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>UpduxConfig | Updux</title><meta name="description" content="Documentation for Updux"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script async src="../assets/search.js" id="search-script"></script></head><body><header><div class="tsd-page-toolbar"><div class="container"><div class="table-wrap"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption">Search</label><input type="text" id="tsd-search-field"/></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">Updux</a></div><div class="table-cell" id="tsd-widgets"><div id="tsd-filter"><a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a><div class="tsd-filter-group"><div class="tsd-select" id="tsd-filter-visibility"><span class="tsd-select-label">All</span><ul class="tsd-select-list"><li data-value="public">Public</li><li data-value="protected">Public/Protected</li><li data-value="private" class="selected">All</li></ul></div> <input type="checkbox" id="tsd-filter-inherited" checked/><label class="tsd-widget" for="tsd-filter-inherited">Inherited</label></div></div><a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a></div></div></div></div><div class="tsd-page-title"><div class="container"><ul class="tsd-breadcrumb"><li><a href="../modules.html">Updux</a></li><li><a href="../modules/_updux_.html">"updux"</a></li><li><a href="_updux_.UpduxConfig.html">UpduxConfig</a></li></ul><h1>Interface UpduxConfig<TState></h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><div class="lead">
|
||||
<p>Configuration object typically passed to the constructor of the class Updux.</p>
|
||||
</div></div></section><section class="tsd-panel tsd-type-parameters"><h3>Type parameters</h3><ul class="tsd-type-parameters"><li><h4>TState = <span class="tsd-signature-type">unknown</span></h4></li></ul></section><section class="tsd-panel tsd-hierarchy"><h3>Hierarchy</h3><ul class="tsd-hierarchy"><li><span class="target">UpduxConfig</span></li></ul></section><section class="tsd-panel-group tsd-index-group"><h2>Index</h2><section class="tsd-panel tsd-index-panel"><div class="tsd-index-content"><section class="tsd-index-section "><h3>Properties</h3><ul class="tsd-index-list"><li class="tsd-kind-property tsd-parent-kind-interface"><a href="_updux_.UpduxConfig.html#actions" class="tsd-kind-icon">actions</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="_updux_.UpduxConfig.html#effects" class="tsd-kind-icon">effects</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="_updux_.UpduxConfig.html#initial" class="tsd-kind-icon">initial</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="_updux_.UpduxConfig.html#mappedReaction" class="tsd-kind-icon">mapped<wbr/>Reaction</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="_updux_.UpduxConfig.html#mappedSelectors" class="tsd-kind-icon">mapped<wbr/>Selectors</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="_updux_.UpduxConfig.html#mutations" class="tsd-kind-icon">mutations</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="_updux_.UpduxConfig.html#reactions" class="tsd-kind-icon">reactions</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="_updux_.UpduxConfig.html#selectors" class="tsd-kind-icon">selectors</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="_updux_.UpduxConfig.html#subduxes" class="tsd-kind-icon">subduxes</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Properties</h2><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a name="actions" class="tsd-anchor"></a><h3><span class="tsd-flag ts-flagOptional">Optional</span> actions</h3><div class="tsd-signature tsd-kind-icon">actions<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span></div><aside class="tsd-sources"></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
||||
<p>Local actions.</p>
|
||||
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a name="effects" class="tsd-anchor"></a><h3><span class="tsd-flag ts-flagOptional">Optional</span> effects</h3><div class="tsd-signature tsd-kind-icon">effects<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">Function</span><span class="tsd-signature-symbol">></span></div><aside class="tsd-sources"></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
||||
<p>Local effects.</p>
|
||||
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a name="initial" class="tsd-anchor"></a><h3><span class="tsd-flag ts-flagOptional">Optional</span> initial</h3><div class="tsd-signature tsd-kind-icon">initial<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type" data-tsd-kind="Type parameter">TState</span></div><aside class="tsd-sources"></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
||||
<p>Local initial state.</p>
|
||||
</div><dl class="tsd-comment-tags"><dt>default</dt><dd><p>{}</p>
|
||||
</dd></dl></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a name="mappedReaction" class="tsd-anchor"></a><h3><span class="tsd-flag ts-flagOptional">Optional</span> mapped<wbr/>Reaction</h3><div class="tsd-signature tsd-kind-icon">mapped<wbr/>Reaction<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Function</span></div><aside class="tsd-sources"></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
||||
<p>If true, enables mapped reactions. Additionally, it can be
|
||||
a reaction function, which will treated as a regular
|
||||
reaction for the mapped dux.</p>
|
||||
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a name="mappedSelectors" class="tsd-anchor"></a><h3><span class="tsd-flag ts-flagOptional">Optional</span> mapped<wbr/>Selectors</h3><div class="tsd-signature tsd-kind-icon">mapped<wbr/>Selectors<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">Function</span><span class="tsd-signature-symbol">></span></div><aside class="tsd-sources"></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
||||
<p> Selectors to apply to the mapped subduxes. Only
|
||||
applicable if the dux is a mapping dux.</p>
|
||||
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a name="mutations" class="tsd-anchor"></a><h3><span class="tsd-flag ts-flagOptional">Optional</span> mutations</h3><div class="tsd-signature tsd-kind-icon">mutations<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">Function</span><span class="tsd-signature-symbol">></span></div><aside class="tsd-sources"></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
||||
<p>Local mutations</p>
|
||||
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a name="reactions" class="tsd-anchor"></a><h3><span class="tsd-flag ts-flagOptional">Optional</span> reactions</h3><div class="tsd-signature tsd-kind-icon">reactions<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">Function</span><span class="tsd-signature-symbol">></span></div><aside class="tsd-sources"></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
||||
<p>Local reactions.</p>
|
||||
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a name="selectors" class="tsd-anchor"></a><h3><span class="tsd-flag ts-flagOptional">Optional</span> selectors</h3><div class="tsd-signature tsd-kind-icon">selectors<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">Function</span><span class="tsd-signature-symbol">></span></div><aside class="tsd-sources"></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
||||
<p>Local selectors.</p>
|
||||
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a name="subduxes" class="tsd-anchor"></a><h3><span class="tsd-flag ts-flagOptional">Optional</span> subduxes</h3><div class="tsd-signature tsd-kind-icon">subduxes<span class="tsd-signature-symbol">?:</span> <a href="../modules.html#Dict" class="tsd-signature-type" data-tsd-kind="Type alias">Dict</a><span class="tsd-signature-symbol"><</span><a href="../classes/_updux_.Updux.html" class="tsd-signature-type" data-tsd-kind="Class">Updux</a><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol"> | </span><a href="_updux_.UpduxConfig.html" class="tsd-signature-type" data-tsd-kind="Interface">UpduxConfig</a><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">></span></div><aside class="tsd-sources"></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
||||
<p>Subduxes to be merged to this dux.</p>
|
||||
</div></div></section></section></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class=""><a href="../modules.html">Exports</a></li><li class="current tsd-kind-namespace"><a href="../modules/_updux_.html">"updux"</a></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul><li class="current tsd-kind-interface tsd-parent-kind-namespace tsd-has-type-parameter"><a href="_updux_.UpduxConfig.html" class="tsd-kind-icon">Updux<wbr/>Config</a><ul><li class="tsd-kind-property tsd-parent-kind-interface"><a href="_updux_.UpduxConfig.html#actions" class="tsd-kind-icon">actions</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="_updux_.UpduxConfig.html#effects" class="tsd-kind-icon">effects</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="_updux_.UpduxConfig.html#initial" class="tsd-kind-icon">initial</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="_updux_.UpduxConfig.html#mappedReaction" class="tsd-kind-icon">mapped<wbr/>Reaction</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="_updux_.UpduxConfig.html#mappedSelectors" class="tsd-kind-icon">mapped<wbr/>Selectors</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="_updux_.UpduxConfig.html#mutations" class="tsd-kind-icon">mutations</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="_updux_.UpduxConfig.html#reactions" class="tsd-kind-icon">reactions</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="_updux_.UpduxConfig.html#selectors" class="tsd-kind-icon">selectors</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="_updux_.UpduxConfig.html#subduxes" class="tsd-kind-icon">subduxes</a></li></ul></li></ul></nav></div></div></div><footer class="with-border-bottom"><div class="container"><h2>Legend</h2><div class="tsd-legend-group"><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li></ul></div><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></div></footer><div class="container tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div><script src="../assets/main.js"></script></body></html>
|
1
docs/API/modules.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><html class="default no-js"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>Updux</title><meta name="description" content="Documentation for Updux"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="assets/style.css"/><link rel="stylesheet" href="assets/highlight.css"/><script async src="assets/search.js" id="search-script"></script></head><body><header><div class="tsd-page-toolbar"><div class="container"><div class="table-wrap"><div class="table-cell" id="tsd-search" data-base="."><div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption">Search</label><input type="text" id="tsd-search-field"/></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="index.html" class="title">Updux</a></div><div class="table-cell" id="tsd-widgets"><div id="tsd-filter"><a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a><div class="tsd-filter-group"><div class="tsd-select" id="tsd-filter-visibility"><span class="tsd-select-label">All</span><ul class="tsd-select-list"><li data-value="public">Public</li><li data-value="protected">Public/Protected</li><li data-value="private" class="selected">All</li></ul></div> <input type="checkbox" id="tsd-filter-inherited" checked/><label class="tsd-widget" for="tsd-filter-inherited">Inherited</label></div></div><a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a></div></div></div></div><div class="tsd-page-title"><div class="container"><h1>Updux</h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel-group tsd-index-group"><h2>Index</h2><section class="tsd-panel tsd-index-panel"><div class="tsd-index-content"><section class="tsd-index-section "><h3>Namespaces</h3><ul class="tsd-index-list"><li class="tsd-kind-namespace"><a href="modules/_updux_.html" class="tsd-kind-icon">"updux"</a></li></ul></section><section class="tsd-index-section "><h3>Type aliases</h3><ul class="tsd-index-list"><li class="tsd-kind-type-alias tsd-has-type-parameter"><a href="modules.html#Dict" class="tsd-kind-icon">Dict</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Type aliases</h2><section class="tsd-panel tsd-member tsd-kind-type-alias tsd-has-type-parameter"><a name="Dict" class="tsd-anchor"></a><h3>Dict</h3><div class="tsd-signature tsd-kind-icon">Dict<T><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">T</span><span class="tsd-signature-symbol">></span></div><aside class="tsd-sources"></aside><h4 class="tsd-type-parameters-title">Type parameters</h4><ul class="tsd-type-parameters"><li><h4>T</h4></li></ul></section></section></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class="current"><a href="modules.html">Exports</a></li><li class=" tsd-kind-namespace"><a href="modules/_updux_.html">"updux"</a></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul><li class="tsd-kind-type-alias tsd-has-type-parameter"><a href="modules.html#Dict" class="tsd-kind-icon">Dict</a></li></ul></nav></div></div></div><footer class="with-border-bottom"><div class="container"><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></div></footer><div class="container tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div><script src="assets/main.js"></script></body></html>
|
1
docs/API/modules/_updux_.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><html class="default no-js"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>"updux" | Updux</title><meta name="description" content="Documentation for Updux"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script async src="../assets/search.js" id="search-script"></script></head><body><header><div class="tsd-page-toolbar"><div class="container"><div class="table-wrap"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption">Search</label><input type="text" id="tsd-search-field"/></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">Updux</a></div><div class="table-cell" id="tsd-widgets"><div id="tsd-filter"><a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a><div class="tsd-filter-group"><div class="tsd-select" id="tsd-filter-visibility"><span class="tsd-select-label">All</span><ul class="tsd-select-list"><li data-value="public">Public</li><li data-value="protected">Public/Protected</li><li data-value="private" class="selected">All</li></ul></div> <input type="checkbox" id="tsd-filter-inherited" checked/><label class="tsd-widget" for="tsd-filter-inherited">Inherited</label></div></div><a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a></div></div></div></div><div class="tsd-page-title"><div class="container"><ul class="tsd-breadcrumb"><li><a href="../modules.html">Updux</a></li><li><a href="_updux_.html">"updux"</a></li></ul><h1>Namespace "updux"</h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel-group tsd-index-group"><h2>Index</h2><section class="tsd-panel tsd-index-panel"><div class="tsd-index-content"><section class="tsd-index-section "><h3>Classes</h3><ul class="tsd-index-list"><li class="tsd-kind-class tsd-parent-kind-namespace tsd-has-type-parameter"><a href="../classes/_updux_.Updux.html" class="tsd-kind-icon">Updux</a></li></ul></section><section class="tsd-index-section "><h3>Interfaces</h3><ul class="tsd-index-list"><li class="tsd-kind-interface tsd-parent-kind-namespace tsd-has-type-parameter"><a href="../interfaces/_updux_.UpduxConfig.html" class="tsd-kind-icon">Updux<wbr/>Config</a></li></ul></section></div></section></section></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class=""><a href="../modules.html">Exports</a></li><li class="current tsd-kind-namespace"><a href="_updux_.html">"updux"</a></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul><li class="tsd-kind-class tsd-parent-kind-namespace tsd-has-type-parameter"><a href="../classes/_updux_.Updux.html" class="tsd-kind-icon">Updux</a></li><li class="tsd-kind-interface tsd-parent-kind-namespace tsd-has-type-parameter"><a href="../interfaces/_updux_.UpduxConfig.html" class="tsd-kind-icon">Updux<wbr/>Config</a></li></ul></nav></div></div></div><footer class="with-border-bottom"><div class="container"><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></div></footer><div class="container tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div><script src="../assets/main.js"></script></body></html>
|
140
docs/index.html
@ -1,128 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title> Home</title>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
|
||||
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
|
||||
<script src="./build/entry.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
|
||||
<link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/app.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/iframe.css">
|
||||
<link type="text/css" rel="stylesheet" href="">
|
||||
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
||||
|
||||
|
||||
<meta charset="UTF-8">
|
||||
<title>updux - Updeep-friendly Redux helper framework</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
||||
<meta name="description" content="Updeep-friendly Redux helper framework">
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css">
|
||||
</head>
|
||||
|
||||
|
||||
|
||||
<body class="layout small-header">
|
||||
<div id="stickyNavbarOverlay"></div>
|
||||
|
||||
|
||||
<div class="top-nav">
|
||||
<div class="inner">
|
||||
<a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
<div class="logo">
|
||||
|
||||
|
||||
</div>
|
||||
<div class="menu">
|
||||
|
||||
<div class="navigation">
|
||||
<a
|
||||
href="index.html"
|
||||
class="link"
|
||||
>
|
||||
API Documentation
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="main">
|
||||
<div
|
||||
class="sidebar "
|
||||
id="sidebarNav"
|
||||
>
|
||||
|
||||
<nav>
|
||||
|
||||
<h2><a href="index.html">Documentation</a></h2><div class="category"><h3>Modules</h3><ul><li><a href="module-updux.html">updux</a></li></ul><h3>Classes</h3><ul><li><a href="Updux.html">Updux</a></li></ul></div>
|
||||
|
||||
</nav>
|
||||
</div>
|
||||
<div class="core" id="main-content-wrapper">
|
||||
<div class="content">
|
||||
<header class="page-title">
|
||||
<p></p>
|
||||
<h1>Home</h1>
|
||||
</header>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3> </h3>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="content has-text-centered">
|
||||
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.7</a></p>
|
||||
<p class="sidebar-created-by">
|
||||
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
||||
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
<div id="side-nav" class="side-nav">
|
||||
</div>
|
||||
</div>
|
||||
<script src="scripts/app.min.js"></script>
|
||||
<script>PR.prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"> </script>
|
||||
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script>
|
||||
window.$docsify = {
|
||||
name: 'updux',
|
||||
repo: 'https://github.com/yanick/updux',
|
||||
loadSidebar: true,
|
||||
subMaxLevel: 4,
|
||||
relativePath: true,
|
||||
}
|
||||
</script>
|
||||
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
|
||||
</body>
|
||||
</html>
|
13
pagesconfig.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"groups": [
|
||||
{
|
||||
"title": "Documentation",
|
||||
"pages": [
|
||||
{
|
||||
"title": "Blah",
|
||||
"source": "./tutorials/tutorial.md"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
20
src/Updux.d.ts
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
type UpduxConfig<TState> = Partial<{
|
||||
initial: TState;
|
||||
subduxes: Record<string,any>;
|
||||
actions: Record<string, any>;
|
||||
selectors: Record<string, Function>;
|
||||
mutations: Record<string, Function>;
|
||||
mappedSelectors: Record<string,Function>;
|
||||
effects: Record<string,Function>;
|
||||
reactions: Record<string,Function>;
|
||||
mappedReaction: Function;
|
||||
}>
|
||||
|
||||
|
||||
export class Updux<TState=unknown> {
|
||||
|
||||
constructor( config: UpduxConfig<TState> );
|
||||
|
||||
get initial(): TState;
|
||||
get selectors(): unknown;
|
||||
}
|
1
src/index.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
export { Updux };
|
@ -1,26 +1,27 @@
|
||||
{
|
||||
"include": ["./types/*.d.ts"],
|
||||
"exclude": [ "types/index.test-d.ts" ],
|
||||
"compilerOptions": {
|
||||
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
||||
|
||||
/* Basic Options */
|
||||
// "incremental": true, /* Enable incremental compilation */
|
||||
"incremental": false, /* Enable incremental compilation */
|
||||
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */
|
||||
"module": "ESNext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
|
||||
// "lib": [], /* Specify library files to be included in the compilation. */
|
||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||
"allowJs": true, /* Allow javascript files to be compiled. */
|
||||
// "checkJs": true, /* Report errors in .js files. */
|
||||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
|
||||
// "declaration": true, /* Generates corresponding '.d.ts' file. */
|
||||
"declaration": true, /* Generates corresponding '.d.ts' file. */
|
||||
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
||||
// "sourceMap": true, /* Generates corresponding '.map' file. */
|
||||
// "outFile": "./", /* Concatenate and emit output to single file. */
|
||||
// "outDir": "./", /* Redirect output structure to the directory. */
|
||||
"outDir": "./ts-out", /* Redirect output structure to the directory. */
|
||||
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||
// "composite": true, /* Enable project compilation */
|
||||
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
||||
// "removeComments": true, /* Do not emit comments to output. */
|
||||
// "noEmit": true, /* Do not emit outputs. */
|
||||
"noEmit": true, /* Do not emit outputs. */
|
||||
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
||||
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
||||
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
||||
@ -48,8 +49,8 @@
|
||||
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
||||
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
||||
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||
// "typeRoots": [], /* List of folders to include type definitions from. */
|
||||
"rootDirs": ["./types"], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||
"typeRoots": ["./types"], /* List of folders to include type definitions from. */
|
||||
// "types": [], /* Type declaration files to be included in compilation. */
|
||||
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
||||
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||
|
@ -1 +0,0 @@
|
||||
window.searchData = {"kinds":{},"rows":[],"index":{"version":"2.3.9","fields":["name","parent"],"fieldVectors":[],"invertedIndex":[],"pipeline":[]}}
|
@ -1 +0,0 @@
|
||||
<!DOCTYPE html><html class="default no-js"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>updux</title><meta name="description" content="Documentation for updux"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="assets/style.css"/><link rel="stylesheet" href="assets/highlight.css"/><script async src="assets/search.js" id="search-script"></script></head><body><header><div class="tsd-page-toolbar"><div class="container"><div class="table-wrap"><div class="table-cell" id="tsd-search" data-base="."><div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption">Search</label><input type="text" id="tsd-search-field"/></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="index.html" class="title">updux</a></div><div class="table-cell" id="tsd-widgets"><div id="tsd-filter"><a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a><div class="tsd-filter-group"><div class="tsd-select" id="tsd-filter-visibility"><span class="tsd-select-label">All</span><ul class="tsd-select-list"><li data-value="public">Public</li><li data-value="protected">Public/Protected</li><li data-value="private" class="selected">All</li></ul></div> <input type="checkbox" id="tsd-filter-inherited" checked/><label class="tsd-widget" for="tsd-filter-inherited">Inherited</label><input type="checkbox" id="tsd-filter-externals" checked/><label class="tsd-widget" for="tsd-filter-externals">Externals</label></div></div><a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a></div></div></div></div><div class="tsd-page-title"><div class="container"><h1> updux</h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class="current"><a href="modules.html">Exports</a></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul></ul></nav></div></div></div><footer class="with-border-bottom"><div class="container"><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></div></footer><div class="container tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div><script src="assets/main.js"></script></body></html>
|
15
typedoc.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "Updux",
|
||||
"entryPoints": [
|
||||
"./types/index.d.ts"
|
||||
],
|
||||
"out": "docs/API",
|
||||
"excludeExternals": true,
|
||||
"excludePrivate": true,
|
||||
"excludeProtected": true,
|
||||
"disableSources": true,
|
||||
"listInvalidSymbolLinks": true,
|
||||
"markedOptions": {
|
||||
"mangle": false
|
||||
}
|
||||
}
|
73
types/index.d.ts
vendored
@ -1,20 +1,63 @@
|
||||
type UpduxConfig<TState> = Partial<{
|
||||
initial: TState;
|
||||
subduxes: Record<string,any>;
|
||||
actions: Record<string, any>;
|
||||
selectors: Record<string, Function>;
|
||||
mutations: Record<string, Function>;
|
||||
mappedSelectors: Record<string,Function>;
|
||||
effects: Record<string,Function>;
|
||||
reactions: Record<string,Function>;
|
||||
mappedReaction: Function;
|
||||
}>
|
||||
type Dict<T> = Record<string, T>;
|
||||
|
||||
declare module 'updux' {
|
||||
/**
|
||||
* Configuration object typically passed to the constructor of the class Updux.
|
||||
*/
|
||||
export interface UpduxConfig<TState = unknown> {
|
||||
/**
|
||||
* Local initial state.
|
||||
* @default {}
|
||||
*/
|
||||
initial?: TState;
|
||||
|
||||
export class Updux<TState=unknown> {
|
||||
/**
|
||||
* Subduxes to be merged to this dux.
|
||||
*/
|
||||
subduxes?: Dict<Updux|UpduxConfig>;
|
||||
|
||||
constructor( config: UpduxConfig<TState> );
|
||||
/**
|
||||
* Local actions.
|
||||
*/
|
||||
actions?: Record<string, any>;
|
||||
|
||||
get initial(): TState;
|
||||
get selectors(): unknown;
|
||||
/**
|
||||
* Local selectors.
|
||||
*/
|
||||
selectors?: Record<string, Function>;
|
||||
|
||||
/**
|
||||
* Local mutations
|
||||
*/
|
||||
mutations?: Record<string, Function>;
|
||||
|
||||
/**
|
||||
* Selectors to apply to the mapped subduxes. Only
|
||||
* applicable if the dux is a mapping dux.
|
||||
*/
|
||||
mappedSelectors?: Record<string, Function>;
|
||||
|
||||
/**
|
||||
* Local effects.
|
||||
*/
|
||||
effects?: Record<string, Function>;
|
||||
|
||||
/**
|
||||
* Local reactions.
|
||||
*/
|
||||
reactions?: Record<string, Function>;
|
||||
/**
|
||||
* If true, enables mapped reactions. Additionally, it can be
|
||||
* a reaction function, which will treated as a regular
|
||||
* reaction for the mapped dux.
|
||||
*/
|
||||
mappedReaction?: Function | boolean;
|
||||
}
|
||||
|
||||
export class Updux<TState = unknown> {
|
||||
constructor(config: Partial<UpduxConfig<TState>>);
|
||||
|
||||
get initial(): TState;
|
||||
get selectors(): unknown;
|
||||
}
|
||||
}
|
||||
|