Skip to content

Commit

Permalink
fix(core): uses take operator when transforming observables into prom…
Browse files Browse the repository at this point in the history
…ises
  • Loading branch information
rafamel committed Oct 24, 2019
1 parent 018c64f commit 5ce0ffc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/core/src/application/merge-intercepts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from '~/inspect';
import { replace } from '~/transform';
import { allof } from '~/create';
import { take } from 'rxjs/operators';

export function mergeIntercepts(
collection: CollectionTreeImplementation
Expand Down Expand Up @@ -65,7 +66,9 @@ export function serviceIntercepts(
resolve(data: any, context, info): Promise<any> {
return interceptFn(data, context, info, (data: any) => {
return from(resolve.call(this, data, context, info));
}).toPromise();
})
.pipe(take(1))
.toPromise();
}
};
}
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/transform/to.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
isServiceImplementation,
isServiceSubscription
} from '~/inspect';
import { take } from 'rxjs/operators';

export function toImplementation<T extends CollectionTree>(
collection: T,
Expand Down Expand Up @@ -64,7 +65,10 @@ export function toUnary<
...element,
kind: 'query',
resolve(...args: any): Promise<any> {
return resolve.apply(this, args).toPromise();
return resolve
.apply(this, args)
.pipe(take(1))
.toPromise();
}
};
}) as AbstractCollectionTree<Q, M, never>;
Expand Down

0 comments on commit 5ce0ffc

Please sign in to comment.