atomic-routes
Advanced tools
Comparing version 0.3.2 to 0.4.0
@@ -13,3 +13,3 @@ (typeof module !== "undefined" && module !== null ? function(moduleBody) { | ||
this._fullPath = this._parent === null ? this._suffix : this._parent._fullPath.concat(this._suffix); | ||
this._isDestroyed = false; | ||
this.isActive = true; | ||
this._listenerList = []; | ||
@@ -25,3 +25,3 @@ this.whenDestroyed = new Promise((function(_this) { | ||
var changeListener, _i, _len, _ref, _results; | ||
if (this._isDestroyed) { | ||
if (!this.isActive) { | ||
throw new Error('already destroyed'); | ||
@@ -40,6 +40,6 @@ } | ||
var changeListener, _i, _len, _ref, _results; | ||
if (this._isDestroyed) { | ||
if (!this.isActive) { | ||
throw new Error('already destroyed'); | ||
} | ||
this._isDestroyed = true; | ||
this.isActive = false; | ||
this._resolveWhenDestroyed(); | ||
@@ -55,5 +55,30 @@ _ref = this._listenerList; | ||
NavigationState.prototype.whenRoot = function(cb) { | ||
var currentState, processPath; | ||
if (!this.isActive) { | ||
throw new Error('already destroyed'); | ||
} | ||
currentState = null; | ||
processPath = (function(_this) { | ||
return function(subPath) { | ||
var isMatching; | ||
isMatching = subPath !== null && subPath.length === 0; | ||
if (currentState !== null && !isMatching) { | ||
currentState._destroy(); | ||
currentState = null; | ||
} | ||
if (isMatching && currentState === null) { | ||
currentState = new NavigationState(_this, [], []); | ||
return cb.call(null, currentState); | ||
} | ||
}; | ||
})(this); | ||
this._listenerList.push(processPath); | ||
processPath(this._currentPath); | ||
return this; | ||
}; | ||
NavigationState.prototype.when = function(suffix, cb) { | ||
var currentArgs, currentState, matchCurrentArgs, matchPath, processPath, suffixPath; | ||
if (this._isDestroyed) { | ||
if (!this.isActive) { | ||
throw new Error('already destroyed'); | ||
@@ -122,3 +147,3 @@ } | ||
var fullPrefix; | ||
if (this._isDestroyed) { | ||
if (!this.isActive) { | ||
throw new Error('already destroyed'); | ||
@@ -125,0 +150,0 @@ } |
@@ -0,0 +0,0 @@ var gulp = require('gulp'); |
@@ -0,0 +0,0 @@ module.exports = function(config) { |
{ | ||
"name": "atomic-routes", | ||
"version": "0.3.2", | ||
"version": "0.4.0", | ||
"main": "dist/atomic-routes.js", | ||
@@ -5,0 +5,0 @@ "description": "Decentralized nested client-side routing with Promises. Framework-agnostic, composable, simple: designed to work with component-based application UIs.", |
@@ -0,0 +0,0 @@ # Atomic Routes |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
17871
210