Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2fb3d5a
Support for angular-ui-router 1.0.0-beta.1 (#64)
rayronvictor Sep 6, 2016
d4fad32
fixed incorrect params being passed in router middleware on STATE_CH…
hally9k Sep 6, 2016
4b5d09a
fix #66 missing parameters passed on transition onStart. Add tests fo…
Nighthawk14 Sep 7, 2016
9bd4b43
Fixed the prev state and params in the redux router state getting set…
hally9k Sep 18, 2016
994b8d0
added options to the state change start action payload for middle war…
hally9k Sep 19, 2016
ecfac55
Add `href` property to the router state object (#51)
rufman Sep 21, 2016
d1f476f
Fix tests and lint (#70)
rufman Sep 21, 2016
ba8d270
Restrict to node v6 and higher (#75)
vlki Nov 10, 2016
da7ebc0
Added MIT license (#79)
hally9k Nov 11, 2016
ae55d4c
Added stateChangeFinish action to ensure state changes are set in the…
hally9k Dec 5, 2016
9ed25bc
upgraded ui-router to 1.0.0-rc1 and fixed node engine bug
Feb 20, 2017
c755e12
upgraded ui-router to 1.0.0-rc1 and fixed node engine bug
Feb 20, 2017
3ae1552
0.7.0-rc.1
Feb 20, 2017
69ae8ab
Expose state activation actions as injectable factory (#81)
NMVW Feb 20, 2017
a2663bb
added the state activation actions as injectable factory
Feb 20, 2017
1eeb5b2
Merge branch 'realease/0.7.1-rc.1' of https://github.com/neilff/redux…
Feb 20, 2017
ea8f31e
0.7.1-rc.1
Feb 20, 2017
e690f66
Merged in umd support
hally9k Apr 29, 2017
d63c54e
Fixed up example
hally9k Apr 29, 2017
a1a5391
bumped patch release
hally9k May 2, 2017
f19c4fe
bumped patch release
hally9k May 2, 2017
ddd8cc3
Upgraded to new ui-router package name
hally9k Jun 4, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"presets": ["es2015"]
"presets": ["es2015", "stage-0"]
}
35 changes: 35 additions & 0 deletions example/devTools.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { createDevTools} from 'redux-devtools';
import { render } from 'react-dom';
import LogMonitor from 'redux-devtools-log-monitor';
import DockMonitor from 'redux-devtools-dock-monitor';
import SliderMonitor from 'redux-slider-monitor';
import React from 'react'
import { Provider } from 'react-redux';

const DevTools = createDevTools(
<DockMonitor toggleVisibilityKey='ctrl-h'
changePositionKey='ctrl-q'
changeMonitorKey='ctrl-m'>
<LogMonitor theme='tomorrow' />
<SliderMonitor keyboardEnabled />
</DockMonitor>
);

export function runDevTools($ngRedux, $rootScope) {
render(
<Provider store={$ngRedux}>
<div>
<DevTools />
</div>
</Provider>,
document.getElementById('devTools')
);

//Hack to reflect state changes when disabling/enabling actions via the monitor
$ngRedux.subscribe(_ => {
setTimeout($rootScope.$apply.bind($rootScope), 100);
});
}

export default DevTools;

1 change: 1 addition & 0 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
</head>
<body>
<main ui-view="main"></main>
<div id="devTools"></div>
</body>
<script src="/static/bundle.js"></script>
</html>
115 changes: 57 additions & 58 deletions example/index.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
import angular from 'angular';
import uiRouter from 'angular-ui-router';
import uiRouter from '@uirouter/angularjs';

import ngRedux from 'ng-redux';
import {combineReducers} from 'redux';
import { combineReducers } from 'redux';
import thunk from 'redux-thunk';
import createLogger from 'redux-logger';
import { default as DevTools, runDevTools } from './devTools';

import ngReduxRouter from '../src';

import {
router,
stateGo,
stateReload,
stateTransitionTo
}
from '../src';
import { router, stateGo, stateReload, stateTransitionTo } from '../src';

const routerActions = {
stateGo,
stateReload,
stateTransitionTo
stateTransitionTo,
};

export default angular
.module('demoApp', [
uiRouter,
ngRedux,
ngReduxRouter
])
.module('demoApp', [uiRouter, ngRedux, ngReduxRouter])
.config(($urlRouterProvider, $stateProvider) => {
$urlRouterProvider.otherwise('/app');

Expand Down Expand Up @@ -60,21 +51,24 @@ export default angular

$ngRedux.connect(state => {
return {
globalState: state
globalState: state,
};
})($scope)
}
}
}
})($scope);
},
},
},
})
.state('app.child1', {
url: '/child1?hello?optional',
views: {
child: {
controller: ($scope, $ngRedux) => {
let disconnect = $ngRedux.connect((state) => state, routerActions)($scope);
const disconnect = $ngRedux.connect(
state => state,
routerActions
)($scope);

$scope.$on('$destroy', disconnect)
$scope.$on('$destroy', disconnect);
},
template: `
<div class="child-view">
Expand All @@ -83,18 +77,21 @@ export default angular
<button ng-click="stateTransitionTo('app.child2')">stateTransitionTo View 2</button>
<button ng-click="stateTransitionTo('app.child3', {id: '4'})">stateTransitionTo View 3, ID: 4</button>
</div>
`
}
}
`,
},
},
})
.state('app.child2', {
url: '/child2',
views: {
child: {
controller: ($scope, $ngRedux) => {
let disconnect = $ngRedux.connect((state) => state, routerActions)($scope);
const disconnect = $ngRedux.connect(
state => state,
routerActions
)($scope);

$scope.$on('$destroy', disconnect)
$scope.$on('$destroy', disconnect);
},
template: `
<div class="child-view">
Expand All @@ -103,22 +100,25 @@ export default angular
<button ng-click="stateReload('app.child1')">$state.reload</button>
<button ng-click="stateGo('app.child1',{hello: 'world', optional: true})">$state.go to View 1 with Params</button>
</div>
`
}
}
`,
},
},
})
.state('app.child3', {
url: '/child3?id',
params: {
hello: 'world'
hello: 'world',
},
reloadOnSearch: false,
views: {
child: {
controller: ($scope, $ngRedux) => {
let disconnect = $ngRedux.connect((state) => state, routerActions)($scope);
const disconnect = $ngRedux.connect(
state => state,
routerActions
)($scope);

$scope.$on('$destroy', disconnect)
$scope.$on('$destroy', disconnect);
},
template: `
<div class="child-view">
Expand All @@ -128,9 +128,9 @@ export default angular
<button ng-click="stateGo('app.child3', {id: '2'})">$state.go View 3, ID: 2</button>
<button ng-click="stateGo('app.child3', {id: '3'})">$state.go View 3, ID: 3</button>
</div>
`
}
}
`,
},
},
})
.state('app.child4', {
url: '/child4',
Expand All @@ -142,42 +142,41 @@ export default angular
<h2>Child View 4</h2>
<div>This state is prohibited. You should've been redirected to the root.</div>
</div>
`
}
}
})
`,
},
},
});
})
.config(($ngReduxProvider) => {
.config($ngReduxProvider => {
const logger = createLogger({
level: 'info',
collapsed: true
collapsed: true,
});

const reducers = combineReducers({
router
router,
});

$ngReduxProvider.createStoreWith(reducers, ['ngUiRouterMiddleware', logger, thunk]);
})
.run(($rootScope, $state, $ngRedux, $urlRouter) => {
const middlewares = ['ngUiRouterMiddleware', thunk, logger];
const enhancers = [DevTools.instrument()];

$ngReduxProvider.createStoreWith(reducers, middlewares, enhancers);
})
.run(runDevTools)
.run(($transitions, $state, $ngRedux) => {
// If save something to the store, dispatch will force state change update
console.log('will do dispatch');
$ngRedux.dispatch({type: 'SOME_ACTION'});
$ngRedux.dispatch({ type: 'SOME_ACTION' });
console.log('did dispatch');

$rootScope.$on('$stateChangeStart', function(evt, to, params) {
if (to.prohibited) {
evt.preventDefault();
const matchCriteria = { to: state => state.prohibited };

$transitions.onBefore(matchCriteria, $transition$ => {
if ($transition$.to().prohibited) {
console.log('prohibited state change cancelled');
$state.go('app');
return $state.target('app', { location: 'replace' });
}
});

console.log('$stateChangeStart callback is ready');
console.log('enable $urlRouter listening');

$urlRouter.sync();
$urlRouter.listen();
})
.name;
console.log('$transitions.onBefore callback is ready');
}).name;
15 changes: 11 additions & 4 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,29 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
"babel-core": "6.13.1",
"babel-loader": "6.2.4",
"babel-core": "6.5.2",
"react": "^15.3.0",
"react-dom": "^15.3.0",
"redux-batched-updates": "0.1.0",
"redux-devtools-dock-monitor": "^1.1.1",
"redux-devtools-log-monitor": "^1.0.11",
"redux-slider-monitor": "^1.0.7",
"webpack": "1.13.1",
"webpack-dev-server": "1.14.1"
},
"license": "MIT",
"dependencies": {
"@uirouter/angularjs": "^1.0.3",
"angular": "^1.5.1",
"angular-ui-router": "0.4.2",
"ng-redux": "^3.3.3",
"react-redux": "^4.4.5",
"redux": "^3.5.2",
"redux-devtools": "^3.3.1",
"redux-logger": "2.6.1",
"redux-thunk": "2.1.0"
},
"engines" : {
"node" : ">=6.0.0"
"engines": {
"node": ">=6.0.0"
}
}
17 changes: 8 additions & 9 deletions example/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ module.exports = {
entry: [
'webpack-dev-server/client?http://localhost:3000',
'webpack/hot/dev-server',
'./index'
'./index',
//Remove the following line to remove devTools
'./devTools.js'
],
output: {
path: path.join(__dirname, 'dist'),
Expand All @@ -17,17 +19,14 @@ module.exports = {
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
],
resolve: {
extensions: ['', '.js'],
alias: {
'react': path.join(__dirname, '..', '..', 'node_modules', 'react')
}
},
module: {
loaders: [{
test: /\.js$/,
loaders: ['babel'],
exclude: /node_modules/
loader: 'babel',
exclude: /node_modules/,
query: {
presets: ['es2015', 'stage-0', 'react']
}
}, {
test: /\.css?$/,
loaders: ['style', 'raw'],
Expand Down
Loading