色々調べたのですが、
callbackの使い方が納得出来ずで、、、
ご教授いただけると助かります。
宜しくお願い致します。
var gulp = require('gulp'); // takes in a callback so the engine knows when it'll be done gulp.task('one', function(cb) { // do stuff -- async or otherwise cb(err); // if err is not null and not undefined, the run will stop, and note that it failed }); // identifies a dependent task must be complete before this one begins gulp.task('two', ['one'], function() { // task 'one' is done now }); gulp.task('default', ['one', 'two']); ```[参照](https://github.com/gulpjs/gulp/blob/master/docs/API.md#gulptaskname--deps--fn) gulpのドキュメントにcallbackの説明が上記のようにありますが、 callbackの機能は 「そのタスクが完了したことをgulpに通知」 するだけなのでしょうか。 サンプルの`cb(err)`の部分ですが、 errにはどういった状況でどういった値がはいるのでしょうか。 また以下のように書いても同じことでしょうか?
var gulp = require('gulp');
// takes in a callback so the engine knows when it'll be done
gulp.task('one', function() {
return gulp.src();
});
// identifies a dependent task must be complete before this one begins
gulp.task('two', ['one'], function() {
console.log('two');
});
gulp.task('default', ['one', 'two']);
どうぞ宜しくお願い致します。
あなたの回答
tips
プレビュー