|
|
|
|
function NextIdPost(type, idDialog){
switch (type) {
case 'messageChat':
redis_cli.incr(type + ':' + idDialog, function( err, id ) {
return id;
});
break
}
}
var id = NextIdPost('messageChat', idDialog);
console.log(id); // undefined
|
| |
|
|
|
|
|
|
|
для: OLi
(02.03.2014 в 22:04)
| | Проблема в асинхронном вызове.
Попробовал так:
function NextIdPost(type, idDialog){
var id ;
switch (type) {
case 'messageChat':
redis_cli.incr(type + ':' + idDialog, function( err, id ) {
id = id;
});
break
}
return id;
}
var id = NextIdPost('messageChat', idDialog);
console.log(id); // undefined
|
| |
|
|
|
|
|
|
|
для: OLi
(02.03.2014 в 22:46)
| | используйте замыкания http://learn.javascript.ru/closures | |
|
|
|