0

I am creating a Chrome Extension that has to deal with Bookmarks. I want multiple (4) events

onCreated
onRemoved
onChanged
onMoved

to perform a single function How do I it? Reference https://developer.chrome.com/extensions/bookmarks#event-onChanged

Anand
  • 610
  • 6
  • 13

1 Answers1

0

It's probably not a very good idea if you want to use the information passed from those events (it's different for every event), but you can do it. Just make a non-anonymous handler and register it for every event:

function universalHandler(a,b) {
  // Do stuff
}

chrome.bookmarks.onCreated.addListener(universalHandler);
chrome.bookmarks.onRemoved.addListener(universalHandler);
chrome.bookmarks.onChanged.addListener(universalHandler);
chrome.bookmarks.onMoved.addListener(universalHandler);
Xan
  • 74,770
  • 16
  • 179
  • 206
  • Can't I do something like http://stackoverflow.com/questions/2534089/jquery-multiple-events-to-trigger-the-same-function – Anand Jan 24 '15 at 16:48
  • I am not using the information passed from events. I want to backup all bookmarks to Google Drive whenever any of these events occur. – Anand Jan 24 '15 at 16:57
  • No, you can't do the same as in jQuery. But the end result does not differ. – Xan Jan 24 '15 at 18:20