Front end of the Slack clone application.

AsyncSubject.js 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /** PURE_IMPORTS_START ._Subject,._Subscription PURE_IMPORTS_END */
  2. var __extends = (this && this.__extends) || function (d, b) {
  3. for (var p in b)
  4. if (b.hasOwnProperty(p))
  5. d[p] = b[p];
  6. function __() { this.constructor = d; }
  7. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8. };
  9. import { Subject } from './Subject';
  10. import { Subscription } from './Subscription';
  11. /**
  12. * @class AsyncSubject<T>
  13. */
  14. export var AsyncSubject = /*@__PURE__*/ (/*@__PURE__*/ function (_super) {
  15. __extends(AsyncSubject, _super);
  16. function AsyncSubject() {
  17. _super.apply(this, arguments);
  18. this.value = null;
  19. this.hasNext = false;
  20. this.hasCompleted = false;
  21. }
  22. /** @deprecated internal use only */ AsyncSubject.prototype._subscribe = function (subscriber) {
  23. if (this.hasError) {
  24. subscriber.error(this.thrownError);
  25. return Subscription.EMPTY;
  26. }
  27. else if (this.hasCompleted && this.hasNext) {
  28. subscriber.next(this.value);
  29. subscriber.complete();
  30. return Subscription.EMPTY;
  31. }
  32. return _super.prototype._subscribe.call(this, subscriber);
  33. };
  34. AsyncSubject.prototype.next = function (value) {
  35. if (!this.hasCompleted) {
  36. this.value = value;
  37. this.hasNext = true;
  38. }
  39. };
  40. AsyncSubject.prototype.error = function (error) {
  41. if (!this.hasCompleted) {
  42. _super.prototype.error.call(this, error);
  43. }
  44. };
  45. AsyncSubject.prototype.complete = function () {
  46. this.hasCompleted = true;
  47. if (this.hasNext) {
  48. _super.prototype.next.call(this, this.value);
  49. }
  50. _super.prototype.complete.call(this);
  51. };
  52. return AsyncSubject;
  53. }(Subject));
  54. //# sourceMappingURL=AsyncSubject.js.map