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 4.1.0 to 5.0.0

25

index.js

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

module.exports = function StateProvider(renderer, rootElement, hashRouter) {
module.exports = function StateProvider(makeRenderer, rootElement, hashRouter) {
var prototypalStateHolder = StateState()

@@ -24,6 +24,6 @@ var current = CurrentState()

var destroyDom = Promise.denodeify(renderer.destroy)
var getDomChild = Promise.denodeify(renderer.getChildElement)
var renderDom = Promise.denodeify(renderer.render)
var resetDom = Promise.denodeify(renderer.reset)
var destroyDom = null
var getDomChild = null
var renderDom = null
var resetDom = null

@@ -249,12 +249,9 @@ var activeDomApis = {}

if (renderer.setUpMakePathFunction) {
renderer.setUpMakePathFunction(stateProviderEmitter.makePath)
}
if (renderer.setUpStateIsActiveFunction) {
renderer.setUpStateIsActiveFunction(stateProviderEmitter.stateIsActive)
}
if (renderer.handleStateRouter) {
renderer.handleStateRouter(stateProviderEmitter)
}
var renderer = makeRenderer(stateProviderEmitter)
destroyDom = Promise.denodeify(renderer.destroy)
getDomChild = Promise.denodeify(renderer.getChildElement)
renderDom = Promise.denodeify(renderer.render)
resetDom = Promise.denodeify(renderer.reset)
return stateProviderEmitter

@@ -261,0 +258,0 @@ }

{
"name": "abstract-state-router",
"version": "4.1.0",
"version": "5.0.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",

@@ -10,6 +10,6 @@ To manage webapp states so that you don't have to deal with url paths or anything.

var stateRouter = createStateRouter(renderer, rootElement, router)
var stateRouter = createStateRouter(makeRenderer, rootElement, router)
```
The `renderer` should be an object with four properties: render, destroy, getChildElement, and reset. Still needs to be documented, see test/support/renderer-mock.js for an implementation.
The `makeRenderer` should be a function that returns an object with four properties: render, destroy, getChildElement, and reset. Still needs to be documented, see test/support/renderer-mock.js for an implementation.

@@ -16,0 +16,0 @@ The `rootElement` is the element where the first-generation states will be created.

@@ -7,20 +7,22 @@ var test = require('tape')

var renderer = {
render: function render(context, cb) {
var element = context.element
var template = context.template
actions.push('render ' + template + ' on ' + element)
cb(null, template)
},
reset: function reset(context, cb) {
actions.push('reset ' + context.domApi)
cb()
},
destroy: function destroy(renderedTemplateApi, cb) {
actions.push('destroy ' + renderedTemplateApi)
cb()
},
getChildElement: function getChildElement(renderedTemplateApi, cb) {
actions.push('getChild ' + renderedTemplateApi)
cb(null, renderedTemplateApi + ' child')
var renderer = function makeRenderer() {
return {
render: function render(context, cb) {
var element = context.element
var template = context.template
actions.push('render ' + template + ' on ' + element)
cb(null, template)
},
reset: function reset(context, cb) {
actions.push('reset ' + context.domApi)
cb()
},
destroy: function destroy(renderedTemplateApi, cb) {
actions.push('destroy ' + renderedTemplateApi)
cb()
},
getChildElement: function getChildElement(renderedTemplateApi, cb) {
actions.push('getChild ' + renderedTemplateApi)
cb(null, renderedTemplateApi + ' child')
}
}

@@ -27,0 +29,0 @@ }

module.exports = function assertingRendererFactory(t, expectedTemplates) {
return {
render: function render(context, cb) {
var template = context.template
t.ok(expectedTemplates.length, 'The render function hasn\'t been called too many times yet')
var expected = expectedTemplates.shift()
t.equal(expected, template, 'The expected template was sent to the render function')
var makeRenderer = function makeRenderer() {
return {
render: function render(context, cb) {
var template = context.template
t.ok(expectedTemplates.length, 'The render function hasn\'t been called too many times yet')
var expected = expectedTemplates.shift()
t.equal(expected, template, 'The expected template was sent to the render function')
process.nextTick(function() {
cb(null, {
template: template
process.nextTick(function() {
cb(null, {
template: template
})
})
})
},
reset: function reset(context, cb) {
setTimeout(cb, 100)
},
destroy: function destroy(renderedTemplateApi, cb) {
setTimeout(cb, 100)
},
getChildElement: function getChildElement(renderedTemplateApi, cb) {
setTimeout(function() {
cb(null, 'dummy child element')
}, 100)
},
expectedAssertions: expectedTemplates.length * 2
},
reset: function reset(context, cb) {
setTimeout(cb, 100)
},
destroy: function destroy(renderedTemplateApi, cb) {
setTimeout(cb, 100)
},
getChildElement: function getChildElement(renderedTemplateApi, cb) {
setTimeout(function() {
cb(null, 'dummy child element')
}, 100)
}
}
}
makeRenderer.expectedAssertions = expectedTemplates.length * 2
return makeRenderer
}

@@ -21,26 +21,27 @@ var myArbitraryRenderFunction = function lol(parent, cb) {

module.exports = {
render: function render(context, cb) {
var element = context.element
var template = context.template
myArbitraryRenderFunction(element, function(renderedTemplateApi) {
cb(null, renderedTemplateApi)
})
},
reset: function reset(context, cb) {
var renderedTemplateApi = context.domApi
var template = context.template
renderedTemplateApi.reset()
setTimeout(cb, 100)
},
destroy: function destroy(renderedTemplateApi, cb) {
renderedTemplateApi.teardown()
setTimeout(cb, 100)
},
getChildElement: function getChildElement(renderedTemplateApi, cb) {
setTimeout(function() {
cb(null, renderedTemplateApi.getChildElement('ui-view'))
}, 100)
},
setUpMakePathFunction: function noop() {}
module.exports = function makeRenderer(stateRouter) {
return {
render: function render(context, cb) {
var element = context.element
var template = context.template
myArbitraryRenderFunction(element, function(renderedTemplateApi) {
cb(null, renderedTemplateApi)
})
},
reset: function reset(context, cb) {
var renderedTemplateApi = context.domApi
var template = context.template
renderedTemplateApi.reset()
setTimeout(cb, 100)
},
destroy: function destroy(renderedTemplateApi, cb) {
renderedTemplateApi.teardown()
setTimeout(cb, 100)
},
getChildElement: function getChildElement(renderedTemplateApi, cb) {
setTimeout(function() {
cb(null, renderedTemplateApi.getChildElement('ui-view'))
}, 100)
}
}
}
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