Issue with async
Opened this issue · 1 comments
fenoria commented
Hello,
I am using director client-side and when i work with async : false
this code is ok:
var routes = {
'/contact': {
on: 'contact'
},
'/event/:eventId': {
'/home': {
on: 'home'
},
'/service/:serviceType': {
on: 'serviceType',
'/:serviceId': {
on: 'serviceId'
}
},
on: 'event'
}
};
var routerContainer = {
event: function (eventId) {
console.log('eventId: ', eventId);
},
home: function () {
console.log('home');
},
contact: function () {
console.log('contact');
},
serviceType: function (eventId, serviceType) {
console.log('serviceType: ', serviceType);
},
serviceId: function (eventId, serviceType, serviceId) {
console.log('serviceId: ', serviceId);
}
};
var routerOptions = {
recurse: 'forward',
resource: routerContainer
};
new Router(routes).configure(routerOptions).init();
I want to do something async in event
function so i update my code like this.
var routerContainer = {
event: function (eventId, next) {
// DO something async
setTimeout(function(){
console.log('eventId: ', eventId);
next();
},1000);
},
home: function (next) {
console.log('home');
next();
},
contact: function (next) {
console.log('contact');
next();
},
serviceType: function (eventId, serviceType,next) {
console.log('serviceType: ', serviceType);
next();
},
serviceId: function (eventId, serviceType, serviceId,next) {
console.log('serviceId: ', serviceId);
next();
}
};
var routerOptions = {
async : true,
recurse: 'forward',
resource: routerContainer
};
With this code the router doesn't executes associated functions (no log)
Any suggestions ?
hrasekj commented
It's becouse method invoke
does not have else if statement for string. My guess is, that this is bug becouse I don't see any reason why async should treat resource differently.