Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
evheniy committed Jun 28, 2018
1 parent 6216145 commit 590dfdf
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Just add reducer to redux and this example should work.
## Documentation

* [Install](https://github.com/evheniy/redux-lazy/blob/master/docs/install.md)
* [How to use](https://github.com/evheniy/redux-lazy/blob/master/docs/use.md)
* [Types](https://github.com/evheniy/redux-lazy/blob/master/docs/types.md)
* [Actions](https://github.com/evheniy/redux-lazy/blob/master/docs/actions.md)
* [Reducer](https://github.com/evheniy/redux-lazy/blob/master/docs/reducer.md)
Expand Down
1 change: 1 addition & 0 deletions docs/actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ describe('Testing actions', () => {
## Documentation

* [Install](https://github.com/evheniy/redux-lazy/blob/master/docs/install.md)
* [How to use](https://github.com/evheniy/redux-lazy/blob/master/docs/use.md)
* [Types](https://github.com/evheniy/redux-lazy/blob/master/docs/types.md)
* [Reducer](https://github.com/evheniy/redux-lazy/blob/master/docs/reducer.md)
* [Container](https://github.com/evheniy/redux-lazy/blob/master/docs/container.md)
Expand Down
1 change: 1 addition & 0 deletions docs/container.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ We can use **nameSpace** for selectors.
## Documentation

* [Install](https://github.com/evheniy/redux-lazy/blob/master/docs/install.md)
* [How to use](https://github.com/evheniy/redux-lazy/blob/master/docs/use.md)
* [Types](https://github.com/evheniy/redux-lazy/blob/master/docs/types.md)
* [Actions](https://github.com/evheniy/redux-lazy/blob/master/docs/actions.md)
* [Reducer](https://github.com/evheniy/redux-lazy/blob/master/docs/reducer.md)
Expand Down
1 change: 1 addition & 0 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ If you need to customize it you can set default state:

## Documentation

* [How to use](https://github.com/evheniy/redux-lazy/blob/master/docs/use.md)
* [Types](https://github.com/evheniy/redux-lazy/blob/master/docs/types.md)
* [Actions](https://github.com/evheniy/redux-lazy/blob/master/docs/actions.md)
* [Reducer](https://github.com/evheniy/redux-lazy/blob/master/docs/reducer.md)
Expand Down
1 change: 1 addition & 0 deletions docs/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ rl.addFormElementAction('title', '');
## Documentation

* [Install](https://github.com/evheniy/redux-lazy/blob/master/docs/install.md)
* [How to use](https://github.com/evheniy/redux-lazy/blob/master/docs/use.md)
* [Types](https://github.com/evheniy/redux-lazy/blob/master/docs/types.md)
* [Actions](https://github.com/evheniy/redux-lazy/blob/master/docs/actions.md)
* [Reducer](https://github.com/evheniy/redux-lazy/blob/master/docs/reducer.md)
Expand Down
1 change: 1 addition & 0 deletions docs/reducer.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ describe('Testing reducer', () => {
## Documentation

* [Install](https://github.com/evheniy/redux-lazy/blob/master/docs/install.md)
* [How to use](https://github.com/evheniy/redux-lazy/blob/master/docs/use.md)
* [Types](https://github.com/evheniy/redux-lazy/blob/master/docs/types.md)
* [Actions](https://github.com/evheniy/redux-lazy/blob/master/docs/actions.md)
* [Container](https://github.com/evheniy/redux-lazy/blob/master/docs/container.md)
Expand Down
1 change: 1 addition & 0 deletions docs/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ describe('Testing types', () => {
## Documentation

* [Install](https://github.com/evheniy/redux-lazy/blob/master/docs/install.md)
* [How to use](https://github.com/evheniy/redux-lazy/blob/master/docs/use.md)
* [Actions](https://github.com/evheniy/redux-lazy/blob/master/docs/actions.md)
* [Reducer](https://github.com/evheniy/redux-lazy/blob/master/docs/reducer.md)
* [Container](https://github.com/evheniy/redux-lazy/blob/master/docs/container.md)
Expand Down
173 changes: 173 additions & 0 deletions docs/use.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
# How to use

## Form

If you need to submit form:

### Redux

Action:
```javascript
export const MODULE_SUBMIT = '@@module/SUBMIT';

export const submitAction = () => ({
type: MODULE_SUBMIT,
});
```
React:
```html
<form onSubmit={(event) => {
event.preventDefault();
props.submitAction();
}}>
```

### Redux Lazy

Action:
```javascript
rl.addFormAction('submit');
```
React:
```html
<form onSubmit={props.submitAction}>
```

## Form Element

If you need to get value from form input (textarea or < input type="text" />):

### Redux

Action:
```javascript
export const MODULE_TITLE = '@@module/TITLE';

export const titleAction = (title) => ({
type: MODULE_SUBMIT,
title,
});
```
React:
```html
<input
type="text"
onChange={event => props.titleAction(event.target.value)}
value={props.title}
/>
```

### Redux Lazy

Action:
```javascript
rl.addFormElementAction('title', 'defaultValue');
```
React:
```html
<input
type="text"
onChange={props.titleAction}
value={props.title}
/>
```

## Event

If you need to get event, for example button click:

```javascript
rl.addEventAction('event');
```
React:
```html
<button onClick={props.eventAction} />
```


## Action with parameter

You can emulate redux action:

```javascript
rl.addParamAction('title', 'defaultValue');

const { actions } = rl.flush();
```
And you will have action:

```javascript
actions.titleActions('text');
```
Result:

```javascript
{
type: types.POST_TITLE,
title: 'text',
}
```

Or with default value:

```javascript
actions.titleActions();
```
Result:

```javascript
{
type: types.POST_TITLE,
title: 'defaultValue',
}
```

## Action with parameters

If you need to update more than one parameter:


```javascript
rl.addParamsAction('clear', { title: 'defaultTitleValue', body: 'defaultBodyValue' });

const { actions } = rl.flush();
```

And you will have action:

```javascript
actions.clearActions('title', 'body');
```
Result:

```javascript
{
type: types.POST_TITLE,
title: 'title',
body: 'body',
}
```

Or with default value:

```javascript
actions.clearActions();
```
Result:

```javascript
{
type: types.POST_TITLE,
title: 'defaultTitleValue',
body: 'defaultBodyValue',
}
```

## Documentation

* [Install](https://github.com/evheniy/redux-lazy/blob/master/docs/install.md)
* [Types](https://github.com/evheniy/redux-lazy/blob/master/docs/types.md)
* [Actions](https://github.com/evheniy/redux-lazy/blob/master/docs/actions.md)
* [Reducer](https://github.com/evheniy/redux-lazy/blob/master/docs/reducer.md)
* [Container](https://github.com/evheniy/redux-lazy/blob/master/docs/container.md)
* [Options](https://github.com/evheniy/redux-lazy/blob/master/docs/options.md)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "redux-lazy",
"version": "0.4.0",
"version": "0.4.1",
"description": "redux-lazy",
"main": "lib/index.js",
"files": [
Expand Down

0 comments on commit 590dfdf

Please sign in to comment.