Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

BehaviorSubject.js 876B

123456789101112131415161718192021222324252627282930313233
  1. import { Subject } from './Subject';
  2. import { ObjectUnsubscribedError } from './util/ObjectUnsubscribedError';
  3. export class BehaviorSubject extends Subject {
  4. constructor(_value) {
  5. super();
  6. this._value = _value;
  7. }
  8. get value() {
  9. return this.getValue();
  10. }
  11. _subscribe(subscriber) {
  12. const subscription = super._subscribe(subscriber);
  13. if (subscription && !subscription.closed) {
  14. subscriber.next(this._value);
  15. }
  16. return subscription;
  17. }
  18. getValue() {
  19. if (this.hasError) {
  20. throw this.thrownError;
  21. }
  22. else if (this.closed) {
  23. throw new ObjectUnsubscribedError();
  24. }
  25. else {
  26. return this._value;
  27. }
  28. }
  29. next(value) {
  30. super.next(this._value = value);
  31. }
  32. }
  33. //# sourceMappingURL=BehaviorSubject.js.map