Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

abstract-state-router

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abstract-state-router - npm Package Compare versions

Comparing version 5.7.1 to 5.8.0

20

index.js

@@ -63,3 +63,3 @@ var StateState = require('./lib/state-state')

function resetStateName(stateName) {
function resetStateName(parameters, stateName) {
activeEmitters[stateName].emit('destroy')

@@ -70,3 +70,4 @@ delete activeEmitters[stateName]

content: getContentObject(activeStateResolveContent, stateName),
template: prototypalStateHolder.get(stateName).template
template: prototypalStateHolder.get(stateName).template,
parameters: parameters
})

@@ -87,3 +88,3 @@ }

function renderStateName(stateName) {
function renderStateName(parameters, stateName) {
return getChildElementForStateName(stateName).then(function(childElement) {

@@ -93,3 +94,4 @@ return renderDom({

template: prototypalStateHolder.get(stateName).template,
content: getContentObject(activeStateResolveContent, stateName)
content: getContentObject(activeStateResolveContent, stateName),
parameters: parameters
})

@@ -102,4 +104,4 @@ }).then(function(domApi) {

function renderAll(stateNames) {
return series(stateNames, renderStateName)
function renderAll(stateNames, parameters) {
return series(stateNames, renderStateName.bind(null, parameters))
}

@@ -189,3 +191,3 @@

}).then(ifNotCancelled(function resolveDestroyAndActivateStates(stateChanges) {
return resolveStates(getStatesToResolve(stateChanges), parameters).catch(function onResolveError(e) {
return resolveStates(getStatesToResolve(stateChanges), extend(parameters)).catch(function onResolveError(e) {
e.stateChangeError = true

@@ -205,5 +207,5 @@ throw e

return series(reverse(stateChanges.destroy), destroyStateName).then(function() {
return series(reverse(stateChanges.change), resetStateName)
return series(reverse(stateChanges.change), resetStateName.bind(null, extend(parameters)))
}).then(function() {
return renderAll(stateChanges.create).then(activateAll)
return renderAll(stateChanges.create, extend(parameters)).then(activateAll)
})

@@ -210,0 +212,0 @@ }))

{
"name": "abstract-state-router",
"version": "5.7.1",
"version": "5.8.0",
"description": "The basics of a client-side state router ala the AngularJS ui-router, but without any DOM interactions",

@@ -39,3 +39,3 @@ "main": "index.js",

"browserify": "11.2.0",
"browserstack-runner": "0.3.7",
"browserstack-runner": "0.3.8",
"browserstack-tape-reporter": "1.0.2",

@@ -42,0 +42,0 @@ "covert": "^1.1.0",

@@ -244,8 +244,10 @@ [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.

It could be me, but probably not in the near future, since I will mostly be using this for form-heavy business apps where generating static HTML isn't really any benefit.
Track development progress in [#48](https://github.com/TehShrike/abstract-state-router/issues/48).
If I use the abstract-state-router on an app where I want to support clients without JS, then I'll start working on the functionality.
It could be added by me, but probably not in the near future, since I will mostly be using this for form-heavy business apps where generating static HTML isn't any benefit.
If anyone else has need of this functionality and wants to get started on it, I'd be happy to help. Stop by the [chat room](https://gitter.im/TehShrike/abstract-state-router) to ask any questions.
If I use the abstract-state-router on an app where I want to support clients without JS, then I'll start working through those tasks in the issue above.
If anyone else has need of this functionality and wants to get keep making progress on it, I'd be happy to help. Stop by the [chat room](https://gitter.im/TehShrike/abstract-state-router) to ask any questions.
# Maintainers

@@ -252,0 +254,0 @@

@@ -33,3 +33,3 @@ # Create your own renderer

Takes an object with three properties:
Is passed an object with four properties:

@@ -39,2 +39,3 @@ - **template**: comes from the original `stateRouter.addState` call when the state was created. The template to be rendered in the DOM. ASR doesn't care at all what this is, so it can be a string, some parsed template object, or anything else - whatever your templating library supports.

- **content** generated by the resolve function provided by the user. If possible, you should apply this object to your DOM interface so that the data will be reflected in the template in the DOM immediately.
- **parameters**: the state parameters

@@ -73,3 +74,3 @@ ```js

Is passed an object with three properties:
Is passed an object with four properties:

@@ -79,2 +80,3 @@ - **domApi**: the object returned by your `render` function

- **template**: the template provided to the `stateRouter.addState` call, same as above
- **parameters**: the state parameters

@@ -81,0 +83,0 @@ This function is similar in function to the `render` function above, but with a difference - the template has already been rendered.

@@ -413,1 +413,41 @@ var test = require('tape-catch')

})
test('render fn receives parameters', function(t) {
t.plan(1)
var stateRouter = getTestState(t, function() {
return {
render: function(context) {
t.deepEqual(context.parameters, {foo: 'abc'})
}
}
}).stateRouter
stateRouter.addState({
name: 'x',
route: '/x/:foo',
template: ''
})
stateRouter.go('x', {foo: 'abc'})
});
test('reset fn receives parameters', function(t) {
t.plan(1)
var stateRouter = getTestState(t, function() {
return {
render: function(context, cb) {
cb()
},
reset: function(context) {
t.deepEqual(context.parameters, {foo: 'def'})
}
}
}).stateRouter
stateRouter.addState({
name: 'x',
route: '/x/:foo',
template: ''
})
stateRouter.on('stateChangeEnd', function() {
stateRouter.go('x', {foo: 'def'})
});
stateRouter.go('x', {foo: 'abc'})
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc