Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Notification.js 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /** PURE_IMPORTS_START _observable_empty,_observable_of,_observable_throwError PURE_IMPORTS_END */
  2. import { empty } from './observable/empty';
  3. import { of } from './observable/of';
  4. import { throwError } from './observable/throwError';
  5. var Notification = /*@__PURE__*/ (function () {
  6. function Notification(kind, value, error) {
  7. this.kind = kind;
  8. this.value = value;
  9. this.error = error;
  10. this.hasValue = kind === 'N';
  11. }
  12. Notification.prototype.observe = function (observer) {
  13. switch (this.kind) {
  14. case 'N':
  15. return observer.next && observer.next(this.value);
  16. case 'E':
  17. return observer.error && observer.error(this.error);
  18. case 'C':
  19. return observer.complete && observer.complete();
  20. }
  21. };
  22. Notification.prototype.do = function (next, error, complete) {
  23. var kind = this.kind;
  24. switch (kind) {
  25. case 'N':
  26. return next && next(this.value);
  27. case 'E':
  28. return error && error(this.error);
  29. case 'C':
  30. return complete && complete();
  31. }
  32. };
  33. Notification.prototype.accept = function (nextOrObserver, error, complete) {
  34. if (nextOrObserver && typeof nextOrObserver.next === 'function') {
  35. return this.observe(nextOrObserver);
  36. }
  37. else {
  38. return this.do(nextOrObserver, error, complete);
  39. }
  40. };
  41. Notification.prototype.toObservable = function () {
  42. var kind = this.kind;
  43. switch (kind) {
  44. case 'N':
  45. return of(this.value);
  46. case 'E':
  47. return throwError(this.error);
  48. case 'C':
  49. return empty();
  50. }
  51. throw new Error('unexpected notification kind value');
  52. };
  53. Notification.createNext = function (value) {
  54. if (typeof value !== 'undefined') {
  55. return new Notification('N', value);
  56. }
  57. return Notification.undefinedValueNotification;
  58. };
  59. Notification.createError = function (err) {
  60. return new Notification('E', undefined, err);
  61. };
  62. Notification.createComplete = function () {
  63. return Notification.completeNotification;
  64. };
  65. Notification.completeNotification = new Notification('C');
  66. Notification.undefinedValueNotification = new Notification('N', undefined);
  67. return Notification;
  68. }());
  69. export { Notification };
  70. //# sourceMappingURL=Notification.js.map