Reputation: 18166
The Chrome Extension Notification API has a create
method with the following signature:
notifications.create(string notificationId, object options, function callback)
I don't actually have a callback that I need to run when the notification finishes, but if I omit the callback, it throws an error:
Error in response to storage.get: Error: Invocation of form notifications.create(string, object, null) doesn't match definition
Fair enough. I don't write a lot of JavaScript. What's the best way to use this API when I want a noop callback?
Upvotes: 1
Views: 1230
Reputation: 150030
If the API forces you to pass some function then you can just pass an empty anonymous function:
notifications.create("idHere", {options:"something"}, function() {});
Or (especially if you need to do it in multiple places) you could explicitly define your own no-op function:
function noop() {}
notifications.create("idHere", {options:"something"}, noop);
someOtherAPI.someMethod(noop);
Upvotes: 2