Skip to content

Commit 4f1dbae

Browse files
committed
Initial commit
0 parents  commit 4f1dbae

File tree

9 files changed

+146
-0
lines changed

9 files changed

+146
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.idea
2+
node_modules
3+
dev_modules
4+
*.log
5+
lib
6+
typings

.npmignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea
2+
node_modules
3+
*.log
4+
typings

.travis.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
language: node_js
2+
sudo: false
3+
node_js:
4+
- 6
5+
6+
cache:
7+
directories:
8+
- node_modules
9+
10+
script:
11+
- npm i -g typings
12+
- typings install
13+
- npm run transpile
14+
15+
deploy:
16+
provider: npm
17+
18+
api_key: $NPM_API_KEY
19+
on:
20+
tags: true
21+
repo: router-async/hook-redux

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Oleg Martynov
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "hook-redux",
3+
"version": "0.0.1",
4+
"author": {
5+
"name": "Oleg Martynov",
6+
"email": "[email protected]"
7+
},
8+
"bugs": {
9+
"url": "https://github.com/router-async/hook-redux/issues"
10+
},
11+
"repository": {
12+
"type": "git",
13+
"url": "https://github.com/router-async/hook-redux.git"
14+
},
15+
"license": "MIT",
16+
"main": "lib/index.js",
17+
"typings": "lib/index.d.ts",
18+
"scripts": {
19+
"clean": "rm -rf lib",
20+
"watch": "npm run clean && tsc -p . --watch",
21+
"transpile": "npm run clean && tsc -p .",
22+
"tsc": "tsc"
23+
},
24+
"devDependencies": {
25+
"typescript": "next"
26+
},
27+
"dependencies": {
28+
"redux-actions-helpers": "1.x.x"
29+
}
30+
}

src/index.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { createAction, handleActions } from 'redux-actions-helpers';
2+
3+
// actions
4+
const startTransition = createAction('@@router/START_TRANSITION', payload => ({ payload }));
5+
const endTransition = createAction('@@router/END_TRANSITION', payload => ({ payload }));
6+
7+
// reducer
8+
const initialState = {
9+
path: null,
10+
route: null,
11+
status: null,
12+
params: null,
13+
redirect: null,
14+
15+
};
16+
export const reducer = handleActions({
17+
[startTransition]: (state, { payload }) => {
18+
// refactor: https://github.com/Microsoft/TypeScript/issues/2103
19+
return Object.assign({}, state, payload);
20+
},
21+
[endTransition]: (state, { payload }) => {
22+
// refactor: https://github.com/Microsoft/TypeScript/issues/2103
23+
return Object.assign({}, state, payload);
24+
}
25+
}, { initialState });
26+
27+
// hook
28+
export const hookRedux = ({ dispatch }) => ({
29+
start: ({ path }) => {
30+
dispatch(startTransition({ path }));
31+
},
32+
resolve: ({ path, route, status, params, redirect }) => {
33+
dispatch(endTransition({ path, route, status, params, redirect }));
34+
}
35+
});

tsconfig.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"module": "commonjs",
5+
"outDir": "./lib"
6+
},
7+
"include": [
8+
"src/**/*",
9+
"typings/index.d.ts"
10+
],
11+
"exclude": [
12+
"node_modules"
13+
]
14+
}

typings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"globalDependencies": {
3+
"es2015": "registry:env/es2015#1.0.0+20160526151700"
4+
}
5+
}

yarn.lock

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
redux-actions-helpers:
4+
version "1.0.2"
5+
resolved "https://registry.yarnpkg.com/redux-actions-helpers/-/redux-actions-helpers-1.0.2.tgz#6d9e1927cdf8d3184cded126a179a2b24d5a8934"
6+
7+
typescript@next:
8+
version "2.1.0-dev.20161027"
9+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.1.0-dev.20161027.tgz#f6456102956dee194398fa1ad093b944c8db4f0a"
10+

0 commit comments

Comments
 (0)