Skip to content

Commit

Permalink
chore: add isPromise change comments
Browse files Browse the repository at this point in the history
  • Loading branch information
arturovt committed Feb 1, 2024
1 parent d696704 commit 7e985c8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/store/src/internal/state-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,12 @@ export class StateFactory implements OnDestroy {
try {
let result = metadata.instance[actionMeta.fn](stateContext, action);

// We need to use `isPromise` instead of checking whether
// `result instanceof Promise`. In zone.js patched environments, `global.Promise`
// is the `ZoneAwarePromise`. Some APIs, which are likely not patched by zone.js
// for certain reasons, might not work with `instanceof`. For instance, the `fetch`
// response `json()` was returning a native promise (not a `ZoneAwarePromise`),
// causing this check to be falsy.
if (ɵisPromise(result)) {
result = from(result);
}
Expand Down

0 comments on commit 7e985c8

Please sign in to comment.