我有这个:
function change( event, file ) {
console.log( "filename", file );
//It should be '_file', not 'file'.
files.clients( file, function( clientOfFile ) {
console.log( "for client:", clientOfFile );
io.sockets.socket( clientOfFile ).emit( "change" );
} );
}
client.on( "watch", function( file ) {
_file = base + file; //filename with path
files.add( _file, client.id );
fs.watch( _file, change );
} );
fs.watch
传递给回调一个没有路径的文件名。所以我希望它得到父函数参数_file
。我以为我可以使用.call
,但如何在回调中做到这一点?