Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(release): 7.0.3 #2915

Merged
merged 20 commits into from
Sep 2, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
onMessage callback should happen in angular zone
  • Loading branch information
jamesdaniels committed Sep 1, 2021
commit 1c804b797bc0e9f13231edf5a6d1d0db85690a85
28 changes: 15 additions & 13 deletions src/zones.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,18 @@ export function ɵkeepUnstableUntilFirstFactory(schedulers: ɵAngularFireSchedul
};
}

const zoneWrapFn = (it: (...args: any[]) => any, macrotask: MacroTask) => {
const zoneWrapFn = (it: (...args: any[]) => any, macrotask: MacroTask|undefined) => {
const _this = this;
// function() is needed for the arguments object
// tslint:disable-next-line:only-arrow-functions
return function() {
setTimeout(() => {
if (macrotask.state === 'scheduled') {
macrotask.invoke();
}
}, 10);
if (macrotask) {
setTimeout(() => {
if (macrotask.state === 'scheduled') {
macrotask.invoke();
}
}, 10);
}
return run(() => it.apply(_this, arguments));
};
};
Expand All @@ -155,15 +157,15 @@ export const ɵzoneWrap = <T= unknown>(it: T, blockUntilFirst: boolean): T => {
// tslint:disable-next-line:only-arrow-functions
return function() {
let macrotask: MacroTask | undefined;
if (blockUntilFirst) {
// if this is a callback function, e.g, onSnapshot, we should create a microtask and invoke it
// only once one of the callback functions is tripped.
for (let i = 0; i < arguments.length; i++) {
if (typeof arguments[i] === 'function') {
// if this is a callback function, e.g, onSnapshot, we should create a microtask and invoke it
// only once one of the callback functions is tripped.
for (let i = 0; i < arguments.length; i++) {
if (typeof arguments[i] === 'function') {
if (blockUntilFirst) {
macrotask ||= run(() => Zone.current.scheduleMacroTask('firebaseZoneBlock', noop, {}, noop, noop));
// TODO create a microtask to track callback functions
arguments[i] = zoneWrapFn(arguments[i], macrotask);
}
// TODO create a microtask to track callback functions
arguments[i] = zoneWrapFn(arguments[i], macrotask);
}
}
const ret = runOutsideAngular(() => (it as any).apply(this, arguments));
Expand Down