├── examples
├── Todo
│ ├── src
│ │ ├── components
│ │ │ ├── Link.js
│ │ │ ├── App.js
│ │ │ ├── helper.js
│ │ │ ├── TodoList.js
│ │ │ └── Todo.js
│ │ ├── index.js
│ │ ├── reducers
│ │ │ ├── index.js
│ │ │ ├── visibilityFilter.js
│ │ │ └── todos.js
│ │ ├── store.js
│ │ └── actions
│ │ │ └── index.js
│ └── todo.html
├── index.html
└── webpack.config.js
├── test
├── index.js
├── connect.spec.js
└── StoreProvider.spec.js
├── src
├── index.js
├── helper.js
├── connect.js
└── StoreProvider.js
├── .gitignore
├── .travis.yml
├── .babelrc
├── .eslintrc
├── gulpfile.js
├── LICENSE
├── webpack.config.js
├── package.json
└── README.md
/examples/Todo/src/components/Link.js:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/index.js:
--------------------------------------------------------------------------------
1 | // @TODO: use jsdom to test
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | export { default as StoreProvider } from './StoreProvider.js'
2 | export { default as connect } from './connect.js'
--------------------------------------------------------------------------------
/examples/Todo/src/index.js:
--------------------------------------------------------------------------------
1 | import App from './components/App';
2 |
3 | const app = new App();
4 | app.$inject(document.getElementById('app'));
5 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | npm-debug.log
3 | .DS_Store
4 | dist
5 | lib
6 | es
7 | .nyc_output
8 | coverage
9 | coverage.lcov
10 | .vscode
11 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - "5"
4 | script:
5 | - npm run lint
6 | - npm run test:cov
7 | after_success:
8 | - npm run coverage
--------------------------------------------------------------------------------
/src/helper.js:
--------------------------------------------------------------------------------
1 | //interfaces
2 | export const IStateFetcher = { $$name: '$$isStateFetcher' };
3 | export const IActionDispatcher = { $$name: '$$isActionDispatcher' };
4 |
5 | IStateFetcher[IStateFetcher.$$name] = true;
6 | IActionDispatcher[IActionDispatcher.$$name] = true;
7 |
--------------------------------------------------------------------------------
/examples/Todo/src/reducers/index.js:
--------------------------------------------------------------------------------
1 | import { combineReducers } from 'redux'
2 | import todos from './todos'
3 | import visibilityFilter from './visibilityFilter'
4 |
5 | const todoApp = combineReducers({
6 | todos,
7 | visibilityFilter
8 | })
9 |
10 | export default todoApp
--------------------------------------------------------------------------------
/examples/Todo/src/reducers/visibilityFilter.js:
--------------------------------------------------------------------------------
1 | const visibilityFilter = (state = 'SHOW_ALL', action) => {
2 | switch (action.type) {
3 | case 'SET_VISIBILITY_FILTER':
4 | return action.filter
5 | default:
6 | return state
7 | }
8 | }
9 |
10 | export default visibilityFilter
--------------------------------------------------------------------------------
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [["es2015"]],
3 | "env": {
4 | "test": {
5 | "plugins": ["istanbul"]
6 | },
7 | "commonjs": {
8 | "presets": [
9 | ["es2015", { "modules": false }]
10 | ]
11 | },
12 | "es": {
13 | "presets": []
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/examples/Todo/src/store.js:
--------------------------------------------------------------------------------
1 | import { createStore } from 'redux';
2 | import todoAppReducer from './reducers';
3 |
4 | export function createTodoStore() {
5 | return createStore((state, action) => {
6 | console.log(action);
7 | return todoAppReducer(state, action);
8 | }, {
9 | todos: []
10 | });
11 | };
--------------------------------------------------------------------------------
/examples/Todo/src/components/App.js:
--------------------------------------------------------------------------------
1 | import Regular from 'regularjs';
2 | import '../../../../src/StoreProvider';
3 | import { createTodoStore } from '../store';
4 | import './TodoList';
5 |
6 | const App = Regular.extend({
7 | name: 'App',
8 | template: `
9 |
10 |
11 |
12 | `,
13 | config(data) {
14 | data.store = createTodoStore()
15 | }
16 | });
17 |
18 | export default App;
--------------------------------------------------------------------------------
/examples/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Examples - RegularRedux
6 |
13 |
14 |
15 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "parser": "babel-eslint",
3 | "extends": [
4 | "eslint:recommended",
5 | "plugin:import/recommended"
6 | ],
7 | "parserOptions": {
8 | "ecmaVersion": 6,
9 | "sourceType": "module",
10 | "ecmaFeatures": {
11 | "experimentalObjectRestSpread": true
12 | }
13 | },
14 | "env": {
15 | "browser": true,
16 | "mocha": true,
17 | "node": true
18 | },
19 | "rules": {
20 | "valid-jsdoc": 2,
21 | "no-console": 0,
22 | "no-unused-vars": 1
23 | },
24 | "plugins": [
25 | "import"
26 | ]
27 | }
--------------------------------------------------------------------------------
/examples/Todo/src/actions/index.js:
--------------------------------------------------------------------------------
1 | let nextTodoId = 0
2 | export const addTodo = (text) => {
3 | return {
4 | type: 'ADD_TODO',
5 | id: nextTodoId++,
6 | text
7 | }
8 | }
9 |
10 | export const setVisibilityFilter = (filter) => {
11 | return {
12 | type: 'SET_VISIBILITY_FILTER',
13 | filter
14 | }
15 | }
16 |
17 | export const toggleTodo = (id) => {
18 | return {
19 | type: 'TOGGLE_TODO',
20 | id
21 | }
22 | }
23 |
24 | export const updateTodo = (id, text) => {
25 | return {
26 | type: 'UPDATE_TODO',
27 | id,
28 | text,
29 | }
30 | }
--------------------------------------------------------------------------------
/examples/Todo/src/components/helper.js:
--------------------------------------------------------------------------------
1 | // helper functions goes here
2 |
3 | /**
4 | * filter visible todos
5 | * @param {Array