Remove many bookmarks > save all bookmarks

Currently i have a AddOn in AMO which can exchange bookmarks via a WebDAV Share. In one of the functions, i export all bookmarks to the share, when a bookmark is removed from the bookmark tree in Firefox. This works good, if you remove only 1 bookmark. But when you remove more than 1 bookmark, for example via the bookmark manager of Firefox, the export of the previous remove isn’t completed. before the new export starts. Is there some way to catch removing of multiple bookmarks and save the bookmarks after all bookmarks are removed from the bookmark tree in Firefox?

You could debounce the call to your listener:

 * Returns a function that executes a callback after it has not been called for a certain time.
 * The arguments and this reference passed to the callback will be those of the last call to the returned function.
 * @param  {function}  callback  The function to call.
 * @param  {natural}   time      The cool down duration in ms.
 * @return {function}            Asynchronous, debounced version of callback.
function debounce(callback, time) {
	let timer = null;
	return function() {
		timer = setTimeout(() => callback.apply(this, arguments), time);
		                         // or just `callback()` if you don't need this/arguments