Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

the compiled result is not suit for ts source file #890

Closed
LinboLen opened this issue Aug 31, 2017 · 3 comments
Closed

the compiled result is not suit for ts source file #890

LinboLen opened this issue Aug 31, 2017 · 3 comments

Comments

@LinboLen
Copy link

LinboLen commented Aug 31, 2017

dist/zone-patch-rxjs.js

 var patchSubscriber = function () {
        var Subscriber$$1 = Rx.Subscriber;
        var next = Subscriber$$1.prototype.next;
        var error = Subscriber$$1.prototype.error;
        var complete = Subscriber$$1.prototype.complete;
        var unsubscribe = Subscriber$$1.prototype.unsubscribe;
        // patch Subscriber.next to make sure it run
        // into SubscriptionZone
        Subscriber$$1.prototype.next = function () {
            var currentZone = Zone.current;
            var subscriptionZone = this._zone;
            // for performance concern, check Zone.current
            // equal with this._zone(SubscriptionZone) or not
            if (subscriptionZone && subscriptionZone !== currentZone) {
                return subscriptionZone.run(next, this, arguments, nextSource);
            }
            else {
                return next.apply(this, arguments);
            }
        };
        Subscriber$$1.prototype.error = function () {
            var currentZone = Zone.current;
            var subscriptionZone = this._zone;
            // for performance concern, check Zone.current
            // equal with this._zone(SubscriptionZone) or not
            if (subscriptionZone && subscriptionZone !== currentZone) {
                return subscriptionZone.run(error, this, arguments, errorSource);
            }
            else {
                return error.apply(this, arguments);
            }
        };
        Subscriber$$1.prototype.complete = function () {
            var currentZone = Zone.current;
            var subscriptionZone = this._zone;
            // for performance concern, check Zone.current
            // equal with this._zone(SubscriptionZone) or not
            if (subscriptionZone && subscriptionZone !== currentZone) {
                return subscriptionZone.run(complete, this, arguments, completeSource);
            }
            else {
                return complete.apply(this, arguments);
            }
        };
        Subscriber$$1.prototype.unsubscribe = function () {
            var currentZone = Zone.current;
            var subscriptionZone = this._zone;
            // for performance concern, check Zone.current
            // equal with this._zone(SubscriptionZone) or not
            if (subscriptionZone && subscriptionZone !== currentZone) {
                return subscriptionZone.run(unsubscribe, this, arguments, unsubscribeSource);
            }
            else {
                return unsubscribe.apply(this, arguments);
            }
        };
    };

lib/rxjs/rxjs.ts

const patchSubscriber = function() {
    const next = Subscriber.prototype.next;
    const error = Subscriber.prototype.error;
    const complete = Subscriber.prototype.complete;

    Object.defineProperty(Subscriber.prototype, 'destination', {
      configurable: true,
      get: function(this: Subscriber<any>) {
        return (this as any)._zoneDestination;
      },
      set: function(this: Subscriber<any>, destination: any) {
        (this as any)._zone = Zone.current;
        (this as any)._zoneDestination = destination;
      }
    });

    // patch Subscriber.next to make sure it run
    // into SubscriptionZone
    Subscriber.prototype.next = function() {
      const currentZone = Zone.current;
      const subscriptionZone = this._zone;

      // for performance concern, check Zone.current
      // equal with this._zone(SubscriptionZone) or not
      if (subscriptionZone && subscriptionZone !== currentZone) {
        return subscriptionZone.run(next, this, arguments, nextSource);
      } else {
        return next.apply(this, arguments);
      }
    };

    Subscriber.prototype.error = function() {
      const currentZone = Zone.current;
      const subscriptionZone = this._zone;

      // for performance concern, check Zone.current
      // equal with this._zone(SubscriptionZone) or not
      if (subscriptionZone && subscriptionZone !== currentZone) {
        return subscriptionZone.run(error, this, arguments, errorSource);
      } else {
        return error.apply(this, arguments);
      }
    };

    Subscriber.prototype.complete = function() {
      const currentZone = Zone.current;
      const subscriptionZone = this._zone;

      // for performance concern, check Zone.current
      // equal with this._zone(SubscriptionZone) or not
      if (subscriptionZone && subscriptionZone !== currentZone) {
        return subscriptionZone.run(complete, this, arguments, completeSource);
      } else {
        return complete.apply(this, arguments);
      }
    };
  };

missing compiled code

Object.defineProperty(Subscriber.prototype, 'destination', {
      configurable: true,
      get: function(this: Subscriber<any>) {
        return (this as any)._zoneDestination;
      },
      set: function(this: Subscriber<any>, destination: any) {
        (this as any)._zone = Zone.current;
        (this as any)._zoneDestination = destination;
      }
    });
@LinboLen
Copy link
Author

fix it with add below into zone-patch-rxjs.js
Line 153

 Object.defineProperty(Subscriber$$1.prototype, 'destination', {
          configurable: true,
          get: function() {
            return this._zoneDestination;
          },
          set: function(destination) {
            this._zone = Zone.current;
            this._zoneDestination = destination;
          }
        });

@JiaLiPassion
Copy link
Collaborator

@LinboLen , if you run npm install zone.js, destination should be there. currently in repository, dist folder is still 0.8.16 version

@LinboLen
Copy link
Author

LinboLen commented Sep 1, 2017

confirm fixed

@LinboLen LinboLen closed this as completed Sep 1, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants