Front end of the Slack clone application.

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