Skip to content

Commit

Permalink
fix(js): Modified internal request class to use getProperty instead o…
Browse files Browse the repository at this point in the history
…f .property due to an issue wit

Typescript currently generates code for drived class's get method by ignoring the type of the child
type completely & directly try and access the property on the parent property, if the property name
exposed on the child is different from the parent, then accessing this property in the generated js
will obviously give undefined value. TO avoid this, I've explicitly added `getProperty` instead of
`get property`
  • Loading branch information
thekalinga committed Feb 2, 2017
1 parent f09d13a commit dfc780d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/interceptor-request-internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ import { InterceptorUtils } from './interceptor-utils';

export class InterceptorRequestInternal extends InterceptorRequest {

get shortCircuitAtCurrentStep(): boolean {
getShortCircuitAtCurrentStep(): boolean {
return this._shortCircuitAtCurrentStep;
}

get alsoForceRequestCompletion(): boolean {
getAlsoForceRequestCompletion(): boolean {
return this._alsoForceRequestCompletion;
}

get alreadyShortCircuited(): boolean {
getAlreadyShortCircuited(): boolean {
return this._alreadyShortCircuited;
}

get shortCircuitTriggeredBy(): number {
getShortCircuitTriggeredBy(): number {
return this._shortCircuitTriggeredBy;
}

get err(): any {
getErr(): any {
return this._err;
}

get errEncounteredAt(): number {
getErrEncounteredAt(): number {
return this._errEncounteredAt;
}

Expand Down
6 changes: 3 additions & 3 deletions src/interceptor-response-wrapper-builder-internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ export class InterceptorResponseWrapperBuilderInternal extends InterceptorRespon
} else {
const request: InterceptorRequestInternal = <InterceptorRequestInternal>from;
InterceptorUtils.assign(builder, request);
if (request.shortCircuitAtCurrentStep) {
builder._shortCircuitTriggeredBy = interceptorStep - 1;
builder._forceRequestCompletion = request.alsoForceRequestCompletion;
if (request.getShortCircuitAtCurrentStep()) {
builder.shortCircuitTriggeredBy(interceptorStep - 1)
.forceRequestCompletion(request.getAlsoForceRequestCompletion());
}
}
return builder;
Expand Down
6 changes: 3 additions & 3 deletions src/interceptor-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,14 @@ export class InterceptorService extends Http {
return this.runBeforeInterceptors(request)
.flatMap<InterceptorRequest, InterceptorResponseWrapper>((transformedRequest: InterceptorRequest, _: number) => {
const transformedRequestInternal = <InterceptorRequestInternal>transformedRequest;
const interceptorRequestInternal = InterceptorRequestBuilderInternal.new(transformedRequestInternal);
const interceptorRequestInternalBuilder = InterceptorRequestBuilderInternal.new(transformedRequestInternal);

if (interceptorRequestInternal.getErr() || interceptorRequestInternal.getAlreadyShortCircuited()) {
if (interceptorRequestInternalBuilder.getErr() || interceptorRequestInternalBuilder.getAlreadyShortCircuited()) {
const responseWrapper = InterceptorResponseWrapperBuilderInternal
.newInternal(this.interceptors.length, transformedRequestInternal)
.build();
return Observable.of(responseWrapper);
} else if (interceptorRequestInternal.getShortCircuitAtCurrentStep()) {
} else if (interceptorRequestInternalBuilder.getShortCircuitAtCurrentStep()) {
const responseWrapper = InterceptorResponseWrapperBuilderInternal
.newInternal(this.interceptors.length, transformedRequestInternal)
.build();
Expand Down

0 comments on commit dfc780d

Please sign in to comment.