abstract-state-router
Advanced tools
Comparing version 5.11.0 to 5.12.0
@@ -1,6 +0,12 @@ | ||
# 5.11.0 | ||
# [5.12.0](https://github.com/TehShrike/abstract-state-router/releases/tag/v5.12.0) | ||
- documentation: documented the `stateChangeError` event | ||
- documentation: documented the `stateError` event | ||
- functional: added the `routeNotFound` event when a route is visited that doesn't have any states associated with it | ||
# [5.11.0](https://github.com/TehShrike/abstract-state-router/releases/tag/v5.11.0) | ||
- functional: added a `parameters` property to the context objects emitted with the `beforeCreateState`, `afterCreateState`, `beforeResetState`, and `afterResetState` events. | ||
# 5.10.0 | ||
# [5.10.0](https://github.com/TehShrike/abstract-state-router/releases/tag/v5.10.0) | ||
@@ -12,7 +18,7 @@ - functional: changed `destroy` to be emitted to the active states after `beforeDestroyState`/`beforeResetState` is emitted on the state router https://github.com/TehShrike/abstract-state-router/commit/8522a300ad23ed45dce0c6be1398bfb3883dd98c | ||
# 5.9.0 | ||
# [5.9.0](https://github.com/TehShrike/abstract-state-router/releases/tag/v5.9.0) | ||
- functional: added emitting events before and after calling every dom rendering function https://github.com/TehShrike/abstract-state-router/pull/54 | ||
# 5.8.1 | ||
# [5.8.1](https://github.com/TehShrike/abstract-state-router/releases/tag/v5.8.1) | ||
@@ -23,4 +29,4 @@ - functional: added console warnings if you call `stateRouter.addState` passing in an object with unexpected properties https://github.com/TehShrike/abstract-state-router/commit/67618b75e7a4e310cb8c3e15f31e3157e2921f6f | ||
# 5.8.0 | ||
# [5.8.0](https://github.com/TehShrike/abstract-state-router/releases/tag/v5.8.0) | ||
- functional: changed parameters objects passed to the DOM rendering functions to be mutable copies instead of being frozen | ||
- functional: changed parameters objects passed to the DOM rendering functions to be mutable copies instead of being frozen |
@@ -35,2 +35,6 @@ var StateState = require('./lib/state-state') | ||
stateRouterOptions.router.setDefault(function(route, parameters) { | ||
stateProviderEmitter.emit('routeNotFound', route, parameters) | ||
}) | ||
current.set('', {}) | ||
@@ -37,0 +41,0 @@ |
{ | ||
"name": "abstract-state-router", | ||
"version": "5.11.0", | ||
"version": "5.12.0", | ||
"description": "The basics of a client-side state router ala the AngularJS ui-router, but without any DOM interactions", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -187,3 +187,15 @@ [ui-router](https://github.com/angular-ui/ui-router/wiki) is fantastic, and I would use it in all of my projects if it wasn't tied to AngularJS. | ||
- `stateChangeEnd(state, parameters)` - after all activate functions are called | ||
- `stateChangeError(err)` - emitted if an error occurs while trying to navigate to a new state - including if you try to navigate to a state that doesn't exist | ||
- `stateError(err)` - emitted if an error occurs in an activation function, or somewhere else that doesn't directly interfere with changing states. Should probably be combined with `stateChangeError` at some point since they're not that different? | ||
- `routeNotFound(route, parameters)` - emitted if the user or some errant code changes the location hash to a route that does not have any states associated with it. If you have a generic "not found" page you want to redirect people to, you can do so like this: | ||
```js | ||
stateRouter.on('routeNotFound', function(route, parameters) { | ||
stateRouter.go('not-found', { | ||
route: route, | ||
parameters: parameters | ||
}) | ||
}) | ||
``` | ||
### DOM API interactions | ||
@@ -190,0 +202,0 @@ |
@@ -417,1 +417,44 @@ var test = require('tape-catch') | ||
}) | ||
test('emitting routeNotFound', function(t) { | ||
var renderer = assertingRendererFactory(t, []) | ||
var state = getTestState(t, renderer) | ||
var stateRouter = state.stateRouter | ||
var assertsBelow = 2 | ||
var renderAsserts = renderer.expectedAssertions | ||
t.plan(assertsBelow + renderAsserts) | ||
stateRouter.addState({ | ||
name: 'valid', | ||
route: '/valid', | ||
template: null, | ||
activate: function(context) { | ||
t.fail('Should never activate the parent\'s state') | ||
} | ||
}) | ||
stateRouter.addState({ | ||
name: 'valid.valid', | ||
route: '/valid', | ||
template: null, | ||
activate: function(context) { | ||
t.fail('Should never activate the child\'s state') | ||
} | ||
}) | ||
stateRouter.on('stateChangeError', function(e) { | ||
t.fail('Should not emit a normal error') | ||
}) | ||
stateRouter.on('stateError', function(e) { | ||
t.fail('Should not emit a normal error') | ||
}) | ||
stateRouter.on('routeNotFound', function(route, parameters) { | ||
t.equal(route, '/nonexistent') | ||
t.equal(parameters.thingy, 'stuff') | ||
t.end() | ||
}) | ||
state.hashRouter.location.go('/nonexistent?thingy=stuff') | ||
}) |
@@ -14,3 +14,2 @@ var hashRouterFactory = require('hash-brown-router') | ||
}, options)) | ||
hashRouter.setDefault(function noop() {}) | ||
@@ -17,0 +16,0 @@ stateRouter.addState({ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
120682
3153
296