registerQuotaErrorCallback.js 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. Copyright 2019 Google LLC
  3. Use of this source code is governed by an MIT-style
  4. license that can be found in the LICENSE file or at
  5. https://opensource.org/licenses/MIT.
  6. */
  7. import { logger } from './_private/logger.js';
  8. import { assert } from './_private/assert.js';
  9. import { quotaErrorCallbacks } from './models/quotaErrorCallbacks.js';
  10. import './_version.js';
  11. /**
  12. * Adds a function to the set of quotaErrorCallbacks that will be executed if
  13. * there's a quota error.
  14. *
  15. * @param {Function} callback
  16. * @memberof module:workbox-core
  17. */
  18. function registerQuotaErrorCallback(callback) {
  19. if (process.env.NODE_ENV !== 'production') {
  20. assert.isType(callback, 'function', {
  21. moduleName: 'workbox-core',
  22. funcName: 'register',
  23. paramName: 'callback',
  24. });
  25. }
  26. quotaErrorCallbacks.add(callback);
  27. if (process.env.NODE_ENV !== 'production') {
  28. logger.log('Registered a callback to respond to quota errors.', callback);
  29. }
  30. }
  31. export { registerQuotaErrorCallback };