Chokidar: How to get the last modification in a dir?

Created on 14 Nov 2013  路  2Comments  路  Source: paulmillr/chokidar

First of all, thanks for this amazing job! I wanna trigger some actions when the last event occur in the dir, how could i do that?

Most helpful comment

Use debounce function for this purpose. You can find one in lodash

var watcher = chokidar.watch('file or dir', {ignored: /^\./, persistent: true});

watcher.on('all', _.debounce(function(event, path) {
  console.log('trigger some action on last occurred event.')
  // max interval between events for this fn to execute is 300ms
}, 300));

All 2 comments

Use debounce function for this purpose. You can find one in lodash

var watcher = chokidar.watch('file or dir', {ignored: /^\./, persistent: true});

watcher.on('all', _.debounce(function(event, path) {
  console.log('trigger some action on last occurred event.')
  // max interval between events for this fn to execute is 300ms
}, 300));

Thanks a lot!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

j-fliegenschmidt picture j-fliegenschmidt  路  6Comments

Pomax picture Pomax  路  3Comments

kevcodez picture kevcodez  路  3Comments

paulmillr picture paulmillr  路  9Comments

jwahlin picture jwahlin  路  7Comments