abstract-state-router
Advanced tools
Comparing version 5.15.0 to 5.15.1
@@ -0,1 +1,6 @@ | ||
# [5.15.1](https://github.com/TehShrike/abstract-state-router/releases/tag/v5.15.1) | ||
- updated hash-brown-router [#93](https://github.com/TehShrike/abstract-state-router/pull/93) | ||
- compatibility: switched from `requre('events').EventEmitter` to `requre('events')` for better Rollup compatibility. [c861f5ab](https://github.com/TehShrike/abstract-state-router/commit/c861f5ab2d0c5d34915c6344fc8ef2d5a7982db2) | ||
# [5.15.0](https://github.com/TehShrike/abstract-state-router/releases/tag/v5.15.0) | ||
@@ -2,0 +7,0 @@ |
@@ -12,3 +12,3 @@ var StateState = require('./lib/state-state') | ||
var EventEmitter = require('events').EventEmitter | ||
var EventEmitter = require('events') | ||
var extend = require('xtend') | ||
@@ -21,3 +21,3 @@ var newHashBrownRouter = require('hash-brown-router') | ||
var expectedPropertiesOfAddState = ['name', 'route', 'defaultChild', 'data', 'template', 'resolve', 'activate', 'querystringParameters', 'defaultQuerystringParameters', 'defaultParameters'] | ||
var expectedPropertiesOfAddState = [ 'name', 'route', 'defaultChild', 'data', 'template', 'resolve', 'activate', 'querystringParameters', 'defaultQuerystringParameters', 'defaultParameters' ] | ||
@@ -39,3 +39,3 @@ module.exports = function StateProvider(makeRenderer, rootElement, stateRouterOptions) { | ||
stateRouterOptions.router.setDefault(function(route, parameters) { | ||
stateRouterOptions.router.on('not found', function(route, parameters) { | ||
stateProviderEmitter.emit('routeNotFound', route, parameters) | ||
@@ -398,3 +398,3 @@ }) | ||
var resolves = Promise.all(statesWithResolveFunctions.map(function(state) { | ||
return new Promise(function (resolve, reject) { | ||
return new Promise(function(resolve, reject) { | ||
function resolveCb(err, content) { | ||
@@ -401,0 +401,0 @@ err ? reject(err) : resolve(content) |
{ | ||
"name": "abstract-state-router", | ||
"version": "5.15.0", | ||
"description": "The basics of a client-side state router ala the AngularJS ui-router, but without any DOM interactions", | ||
"version": "5.15.1", | ||
"description": "Like ui-router, but without all the Angular. The best way to structure a single-page webapp.", | ||
"main": "index.js", | ||
@@ -30,11 +30,11 @@ "scripts": { | ||
"combine-arrays": "~1.0.2", | ||
"hash-brown-router": "~1.5.0", | ||
"hash-brown-router": "~3.0.2", | ||
"native-promise-only": "0.8.1", | ||
"page-path-builder": "~1.0.3", | ||
"path-to-regexp-with-reversible-keys": "~1.0.3", | ||
"then-denodeify": "1.0.0", | ||
"then-denodeify": "1.0.1", | ||
"xtend": "^4.0.0" | ||
}, | ||
"devDependencies": { | ||
"browserify": "13.1.1", | ||
"browserify": "14.0.0", | ||
"browserstack-runner": "TehShrike/browserstack-runner#fixing-json-borking", | ||
@@ -47,5 +47,5 @@ "browserstack-tape-reporter": "~1.1.0", | ||
"tape-catch": "1.0.6", | ||
"watchify": "3.7.0", | ||
"watchify": "3.9.0", | ||
"webpack": "^1.12.14" | ||
} | ||
} |
@@ -1,9 +0,7 @@ | ||
[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. | ||
abstract-state-router lets you build single-page webapps using nested routes/states. Your code doesn't reference routes directly, like `/app/users/josh`, but by name and properties, like `app.user` + `{ name: 'josh' }`. | ||
But I don't want to use AngularJS - I want to use *[my favorite templating/dom manipulation libraries here]*. | ||
To find out why you should be using this kind of router, read [Why Your Webapp Needs a State-Based Router](http://joshduff.com/#!/post/2015-06-why-you-need-a-state-router.md). | ||
Thus, this library! Written to work with [browserify](https://github.com/substack/node-browserify), it lets you create nested "states" that correspond to different parts of the url path. | ||
abstract-state-router is heavily inspired by [ui-router](https://github.com/angular-ui/ui-router/wiki). The biggest difference is: you can use abstract-state-router with whatever templating/component library you like. | ||
If you've never used AngularJS's ui-router before, check out this post: [Why your webapp needs a state-based router](http://joshduff.com/#!/post/2015-06-why-you-need-a-state-router.md). | ||
To see an example app implemented with a couple of different browser rendering libraries, [click here to visit the state-router-example on Github Pages](http://tehshrike.github.io/state-router-example). | ||
@@ -19,4 +17,5 @@ | ||
- [Knockout](https://github.com/crissdev/knockout-state-renderer) | ||
- [Svelte](https://github.com/TehShrike/svelte-state-renderer) | ||
If you want to use the state router with some other templating/dom manipulation library, [read these docs](https://github.com/TehShrike/abstract-state-router/blob/master/renderer.md)! It's not too bad to get started. | ||
If you want to use the state router with any other templating/dom manipulation library, [read these docs](https://github.com/TehShrike/abstract-state-router/blob/master/renderer.md)! It's not too bad to get started. | ||
@@ -29,3 +28,3 @@ # Install | ||
npm install abstract-state-router | ||
npm install abstract-state-router -S | ||
@@ -55,3 +54,3 @@ ``` | ||
- `pathPrefix` defaults to `'#'`. If you're using HTML5 routing/pushState, you'll most likely want to set this to an empty string. | ||
- `router` defaults to an instance of a [hash brown router](https://github.com/TehShrike/hash-brown-router/). The abstract-state-router unit tests use the [hash brown router stub](https://github.com/TehShrike/hash-brown-router/#testability). To use pushState, pass in a hash brown router created with [sausage-router](https://github.com/TehShrike/sausage-router). | ||
- `router` defaults to an instance of a [hash brown router@3.x](https://github.com/TehShrike/hash-brown-router/). The abstract-state-router unit tests use the [hash brown router stub](https://github.com/TehShrike/hash-brown-router/#testability). To use pushState, pass in a hash brown router created with [sausage-router](https://github.com/TehShrike/sausage-router). | ||
- `throwOnError` defaults to true, because you get way better stack traces in Chrome when you throw than if you `console.log(err)` or emit `'error'` events. The unit tests disable this. | ||
@@ -67,4 +66,6 @@ | ||
`defaultChild` is a string (or a function that returns a string) of the default child's name. If you attempt to go directly to a state that has a default child, you will be directed to the default child. (For example, you could set 'list' to be the default child of 'contacts'. Then doing `state.go('contacts')` will actually do `state.go('contacts.list')`. Likewise, browsing to '/tehshrike/contacts' would bring you to '/tehshrike/contacts/list'.) | ||
`defaultChild` is a string (or a function that returns a string) of the default child's name. Use the short name (`list`), not the fully qualified name with all its parents (`contacts.list`). | ||
If the viewer navigates to a state that has a default child, the router will redirect to the default child. (For example, if 'list' is the default child of 'contacts', `state.go('contacts')` will actually be equivalent to `state.go('contacts.list')`. Likewise, browsing to '/tehshrike/contacts' would take the viewer to '/tehshrike/contacts/list'.) | ||
`data` is an object that can hold whatever you want - it will be passed in to the resolve and activate functions. | ||
@@ -92,2 +93,17 @@ | ||
If you want to redirect with promises, return a rejected promise with an object containing a `redirectTo` property with `name` and `params` values for the state to redirect to. | ||
```js | ||
function resolve(data, parameters) { | ||
return Promise.reject({ | ||
redirectTo: { | ||
name: 'otherCoolState', | ||
params: { | ||
extraCool: true | ||
} | ||
} | ||
}) | ||
} | ||
``` | ||
### activate(context) | ||
@@ -94,0 +110,0 @@ |
Sorry, the diff of this file is not supported yet
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
138925
338
+ Addedarray-buffer-byte-length@1.0.2(transitive)
+ Addedarray.prototype.find@2.0.0(transitive)
+ Addedarraybuffer.prototype.slice@1.0.4(transitive)
+ Addedavailable-typed-arrays@1.0.7(transitive)
+ Addedcall-bind@1.0.8(transitive)
+ Addedcall-bind-apply-helpers@1.0.1(transitive)
+ Addedcall-bound@1.0.3(transitive)
+ Addeddata-view-buffer@1.0.2(transitive)
+ Addeddata-view-byte-length@1.0.2(transitive)
+ Addeddata-view-byte-offset@1.0.1(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddefine-properties@1.2.1(transitive)
+ Addeddunder-proto@1.0.1(transitive)
+ Addedes-abstract@1.23.7(transitive)
+ Addedes-define-property@1.0.1(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.0.0(transitive)
+ Addedes-set-tostringtag@2.0.3(transitive)
+ Addedes-to-primitive@1.3.0(transitive)
+ Addedfor-each@0.3.3(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedfunction.prototype.name@1.1.8(transitive)
+ Addedfunctions-have-names@1.2.3(transitive)
+ Addedget-intrinsic@1.2.6(transitive)
+ Addedget-symbol-description@1.1.0(transitive)
+ Addedglobalthis@1.0.4(transitive)
+ Addedgopd@1.2.0(transitive)
+ Addedhas-bigints@1.1.0(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.2.0(transitive)
+ Addedhas-symbols@1.1.0(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedhash-brown-router@3.0.2(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedinternal-slot@1.1.0(transitive)
+ Addedis-array-buffer@3.0.5(transitive)
+ Addedis-async-function@2.0.0(transitive)
+ Addedis-bigint@1.1.0(transitive)
+ Addedis-boolean-object@1.2.1(transitive)
+ Addedis-callable@1.2.7(transitive)
+ Addedis-data-view@1.0.2(transitive)
+ Addedis-date-object@1.1.0(transitive)
+ Addedis-finalizationregistry@1.1.1(transitive)
+ Addedis-generator-function@1.0.10(transitive)
+ Addedis-map@2.0.3(transitive)
+ Addedis-number-object@1.1.1(transitive)
+ Addedis-regex@1.2.1(transitive)
+ Addedis-set@2.0.3(transitive)
+ Addedis-shared-array-buffer@1.0.4(transitive)
+ Addedis-string@1.1.1(transitive)
+ Addedis-symbol@1.1.1(transitive)
+ Addedis-typed-array@1.1.15(transitive)
+ Addedis-weakmap@2.0.2(transitive)
+ Addedis-weakref@1.1.0(transitive)
+ Addedis-weakset@2.0.4(transitive)
+ Addedisarray@2.0.5(transitive)
+ Addedmath-intrinsics@1.1.0(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedobject-keys@1.1.1(transitive)
+ Addedobject.assign@4.1.7(transitive)
+ Addedpossible-typed-array-names@1.0.0(transitive)
+ Addedreflect.getprototypeof@1.0.9(transitive)
+ Addedregexp.prototype.flags@1.5.3(transitive)
+ Addedsafe-array-concat@1.1.3(transitive)
+ Addedsafe-regex-test@1.1.0(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedset-function-name@2.0.2(transitive)
+ Addedside-channel@1.1.0(transitive)
+ Addedside-channel-list@1.0.0(transitive)
+ Addedside-channel-map@1.0.1(transitive)
+ Addedside-channel-weakmap@1.0.2(transitive)
+ Addedstring.prototype.trim@1.2.10(transitive)
+ Addedstring.prototype.trimend@1.0.9(transitive)
+ Addedstring.prototype.trimstart@1.0.8(transitive)
+ Addedthen-denodeify@1.0.1(transitive)
+ Addedtyped-array-buffer@1.0.3(transitive)
+ Addedtyped-array-byte-length@1.0.3(transitive)
+ Addedtyped-array-byte-offset@1.0.4(transitive)
+ Addedtyped-array-length@1.0.7(transitive)
+ Addedunbox-primitive@1.1.0(transitive)
+ Addedwhich-boxed-primitive@1.1.1(transitive)
+ Addedwhich-builtin-type@1.2.1(transitive)
+ Addedwhich-collection@1.0.2(transitive)
+ Addedwhich-typed-array@1.1.18(transitive)
- Removedarray.prototype.find@1.0.0(transitive)
- Removedhash-brown-router@1.5.3(transitive)
- Removedthen-denodeify@1.0.0(transitive)
Updatedhash-brown-router@~3.0.2
Updatedthen-denodeify@1.0.1