14.3.1 • Published 6 years ago

alp-react-redux v14.3.1

Weekly downloads
3
License
ISC
Repository
github
Last release
6 years ago

How to install

npm install --save koa@2 alp-react-redux

Examples

With Koa

import Koa from 'koa';
import reactredux from 'alp-react-redux';
import moduleDescriptor from './reduxApp';

const app = new Koa();
reactredux()(app);

// ...

(ctx) => {
    ctx.render(moduleDescriptor, data);
}

With Ibex

import Ibex from 'ibex';
import reactredux from 'alp-react-redux';
import moduleDescriptor from './reduxApp';

const const app = new Ibex();
reactredux({
    moduleDescriptor,
    initialData: window.__INITIAL_STATE__,
})(app);


// ...

(ctx) => {
    ctx.render(moduleDescriptor, data);
}

How it works

alp-react-redux render react components.

It add in Koa's context (or Ibex's context) the following method:

render(moduleDescriptor, data)

moduleDescriptor is an object with two properties: View and optional reducer. If the reducer is not set, the view is rendered as a simple component. data is an object with the initial data, sent to redux as the initial data for the store, or to react simple component as properties

For browser, this package keeps a single redux store, and reinitialize it each time the render method is called.

createAction / createReducer

Reduce some boilerplate in your application:

import { createAction, createReducer } from 'alp-react-redux';


export const increment = createAction('INCREMENT');
export const addTodo = createAction('ADD_TODO'); // addTodo({ name: 'Todo Name' })
export const removeTodo = createAction('REMOVE_TODO', ['id']); // removeTodo(todo.id)

export default createReducer(() => [], {
    [addTodo]: (todos, todo) => [...todos, todo],
    [removeTodo]: (state, { id }) => todos.filter(todo => todo.id !== id),
});
14.3.1

6 years ago

14.3.0

6 years ago

14.2.3

6 years ago

14.2.2

6 years ago

14.2.1

7 years ago

14.2.0

7 years ago

14.0.0

7 years ago

12.1.1

7 years ago

12.1.0

7 years ago

12.0.0

7 years ago

11.0.0

7 years ago

10.1.1

7 years ago

10.1.0

7 years ago

10.0.0

7 years ago

9.0.0

7 years ago

8.2.1

7 years ago

8.2.0

7 years ago

8.1.0

7 years ago

8.0.0

7 years ago

7.3.3

7 years ago

7.3.2

7 years ago

7.3.1

7 years ago

7.3.0

7 years ago

7.2.0

7 years ago

7.1.1

7 years ago

7.1.0

7 years ago

7.0.0

7 years ago

6.0.5

7 years ago

6.0.4

7 years ago

6.0.3

7 years ago

6.0.2

7 years ago

6.0.1

8 years ago

6.0.0

8 years ago

6.0.0-beta.6

8 years ago

6.0.0-beta.5

8 years ago

6.0.0-beta.4

8 years ago

6.0.0-beta.3

8 years ago

6.0.0-beta.2

8 years ago

6.0.0-beta.1

8 years ago

5.2.1

8 years ago

5.2.0

8 years ago

5.1.0

8 years ago

5.0.1

8 years ago

5.0.0

8 years ago

4.7.4

8 years ago

4.7.3

8 years ago

4.7.2

8 years ago

4.7.1

8 years ago

4.7.0

8 years ago

4.6.0

8 years ago

4.5.0

8 years ago

4.4.0

8 years ago

4.3.0

8 years ago

4.2.2

8 years ago

4.2.1

8 years ago

4.2.0

8 years ago

4.1.0

8 years ago

4.0.0

8 years ago

3.3.0

8 years ago

3.2.0

8 years ago

3.1.0

8 years ago

3.0.0

8 years ago

2.2.1

8 years ago

2.2.0

8 years ago

2.1.0

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.0.0

8 years ago