Source: externs/shaka/abortable.js

  1. /**
  2. * @license
  3. * Copyright 2016 Google Inc.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /** @externs */
  18. /**
  19. * A representation of an abortable operation. Note that these are not
  20. * cancelable. Cancelation implies undoing what has been done so far,
  21. * whereas aborting only means that futher work is stopped.
  22. *
  23. * @interface
  24. * @template T
  25. * @exportDoc
  26. */
  27. shakaExtern.IAbortableOperation;
  28. /**
  29. * A Promise which represents the underlying operation. It is resolved when
  30. * the operation is complete, and rejected if the operation fails or is
  31. * aborted. Aborted operations should be rejected with a shaka.util.Error
  32. * object using the error code OPERATION_ABORTED.
  33. *
  34. * @const {!Promise.<T>}
  35. * @exportDoc
  36. */
  37. shakaExtern.IAbortableOperation.prototype.promise;
  38. /**
  39. * Can be called by anyone holding this object to abort the underlying
  40. * operation. This is not cancelation, and will not necessarily result in
  41. * any work being undone. abort() should return a Promise which is resolved
  42. * when the underlying operation has been aborted. The returned Promise
  43. * should never be rejected.
  44. *
  45. * @return {!Promise}
  46. * @exportDoc
  47. */
  48. shakaExtern.IAbortableOperation.prototype.abort = function() {};
  49. /**
  50. * @param {function(boolean)} onFinal A callback to be invoked after the
  51. * operation succeeds or fails. The boolean argument is true if the operation
  52. * succeeded and false if it failed.
  53. * @return {!shakaExtern.IAbortableOperation.<T>} Returns this.
  54. * @exportDoc
  55. */
  56. shakaExtern.IAbortableOperation.prototype.finally = function(onFinal) {};