Comparing version 0.0.5 to 0.1.0
@@ -9,2 +9,3 @@ 'use strict'; | ||
var locationStore = require('./location'); | ||
var isobject = require('formula/fn/isobject'); | ||
var isfunction = require('formula/fn/isfunction'); | ||
@@ -46,2 +47,7 @@ | ||
if (action.type === 'loadContent') { | ||
// console.log('loadContent in router', state, action) | ||
return Object.assign({}, state, { content: action.data }); | ||
} | ||
if (action.type === 'loadRoutes') { | ||
@@ -93,17 +99,15 @@ routes = action.data; | ||
// run the action method defined by the router | ||
if (route.load.then) { | ||
// console.log("THEN", route) | ||
route.load.then(function (content) { | ||
return dispatch({ | ||
type: 'loadContent', | ||
content: content, | ||
params: params, | ||
args: args, | ||
route: route | ||
}); | ||
}); | ||
} else if (isfunction(route.load)) { | ||
content = route.load; | ||
if (isfunction(content)) { | ||
// console.log("THUNK", route, typeof route.load) | ||
content = route.load(params); | ||
} | ||
if (isobject(content) && content.then) { | ||
// console.log("THEN", route) | ||
content.then(function (cmp) { | ||
return dispatch('loadContent', cmp); | ||
}); | ||
} | ||
} | ||
@@ -110,0 +114,0 @@ |
{ | ||
"name": "rootr", | ||
"version": "0.0.5", | ||
"version": "0.1.0", | ||
"description": "Router for single page app.", | ||
@@ -28,5 +28,5 @@ "repository": { | ||
"babel-preset-react": "^6.11.1", | ||
"fluxury": "^3.0.0", | ||
"gulp": "^3.9.1", | ||
"gulp-babel": "^6.1.2", | ||
"pure-flux": "^1.1.0", | ||
"react": "^15.3.2", | ||
@@ -33,0 +33,0 @@ "react-dom": "^15.3.2", |
@@ -73,4 +73,5 @@ // mock browser globals | ||
var { createStore, dispatch, promiseAction } = require('pure-flux') | ||
var { createStore, dispatch, promiseAction, subscribe } = require('fluxury') | ||
//subscribe((state, action) => console.log('action', action)) | ||
var router= require('./src/index') | ||
@@ -85,3 +86,3 @@ var { location, replaceRoutes, loadContent, loadRoutes, promiseContent } = require('./src/index') | ||
path: '/admin', | ||
load: () => testComponent | ||
load: () => Promise.resolve(testComponent) | ||
}, { | ||
@@ -135,2 +136,3 @@ path: '/admin2', | ||
var result = yield location.open('/') | ||
@@ -137,0 +139,0 @@ var rs = router.getState; |
Sorry, the diff of this file is not supported yet
110361
304