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

refactor: Replace Zone.scheduleMacroTask with ExperimentalPendingTasks #3542

Merged
merged 4 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1,150 changes: 1,051 additions & 99 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
},
"devDependencies": {
"@angular-devkit/build-angular": "^18.0.0",
"@angular-eslint/builder": "^18.0.1",
"@angular-eslint/eslint-plugin": "^18.0.1",
"@angular/animations": "^18.0.0",
"@angular/cli": "^18.0.0",
"@angular/compiler-cli": "^18.0.0",
Expand All @@ -90,8 +92,8 @@
"@types/semver": "^7.1.0",
"@types/triple-beam": "^1.3.0",
"@types/winston": "^2.4.4",
"@typescript-eslint/eslint-plugin": "6.13.1",
"@typescript-eslint/parser": "6.13.1",
"@typescript-eslint/eslint-plugin": "^7.11.0",
"@typescript-eslint/parser": "^7.11.0",
"conventional-changelog-cli": "^1.2.0",
"cross-spawn": "^7.0.3",
"eslint": "^8.54.0",
Expand All @@ -118,4 +120,4 @@
"typescript": ">=5.4 <5.5"
},
"typings": "index.d.ts"
}
}
6 changes: 3 additions & 3 deletions src/analytics/firebase.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/auth/rxfire.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions src/compat/angularfire2.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CompilerFactory, DoBootstrap, NgModule, NgZone, PlatformRef } from '@angular/core';
import { CompilerFactory, DoBootstrap, ExperimentalPendingTasks, NgModule, NgZone, PlatformRef } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { ɵAngularFireSchedulers, ɵZoneScheduler, ɵkeepUnstableUntilFirstFactory } from '@angular/fire';
import { AngularFireModule, FirebaseApp } from '@angular/fire/compat';
Expand Down Expand Up @@ -89,7 +89,7 @@ describe('angularfire', () => {
let schedulers: ɵAngularFireSchedulers;
let outsideZone: Zone;
let insideZone: Zone;
beforeAll(() => {
beforeEach(() => {
outsideZone = Zone.current;
insideZone = Zone.current.fork({
name: 'ngZone'
Expand All @@ -100,7 +100,7 @@ describe('angularfire', () => {
runOutsideAngular: outsideZone.runGuarded.bind(outsideZone),
runTask: insideZone.run.bind(insideZone)
} as NgZone;
schedulers = new ɵAngularFireSchedulers(ngZone);
schedulers = new ɵAngularFireSchedulers(ngZone, TestBed.inject(ExperimentalPendingTasks));
});

it('should re-schedule emissions asynchronously', done => {
Expand Down Expand Up @@ -157,7 +157,8 @@ describe('angularfire', () => {
runTask: insideZone.run.bind(insideZone)
} as NgZone,
outsideAngular: new ɵZoneScheduler(outsideZone, testScheduler),
insideAngular: new ɵZoneScheduler(insideZone, testScheduler)
insideAngular: new ɵZoneScheduler(insideZone, testScheduler),
pendingTasks: TestBed.inject(ExperimentalPendingTasks),
};
const keepUnstableOp = ɵkeepUnstableUntilFirstFactory(trackingSchedulers);

Expand Down
6 changes: 3 additions & 3 deletions src/compat/database/database.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { NgZone } from '@angular/core';
import { ExperimentalPendingTasks, NgZone } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { ɵAngularFireSchedulers } from '@angular/fire';
import { AngularFireModule, FIREBASE_APP_NAME, FIREBASE_OPTIONS, FirebaseApp } from '@angular/fire/compat';
import { AngularFireDatabase, AngularFireDatabaseModule, URL } from '@angular/fire/compat/database';
import 'firebase/compat/database';
import { COMMON_CONFIG } from '../../../src/test-config';
import { rando } from '../../../src/utils';
import 'firebase/compat/database';

describe('AngularFireDatabase', () => {
let app: FirebaseApp;
Expand Down Expand Up @@ -41,7 +41,7 @@ describe('AngularFireDatabase', () => {
});

it('should accept a Firebase App in the constructor', (done) => {
const schedulers = new ɵAngularFireSchedulers(zone);
const schedulers = new ɵAngularFireSchedulers(zone, TestBed.inject(ExperimentalPendingTasks));
const database = new AngularFireDatabase(
app.options, rando(), undefined, {}, zone, schedulers, undefined, undefined,
undefined, undefined, undefined, undefined, undefined, undefined, undefined,
Expand Down
4 changes: 2 additions & 2 deletions src/compat/firestore/collection/changes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function sliceAndSplice<T>(
export function combineChange<T>(combined: DocumentChange<T>[], change: DocumentChange<T>): DocumentChange<T>[] {
switch (change.type) {
case 'added':
if (combined[change.newIndex] && combined[change.newIndex].doc.ref.isEqual(change.doc.ref)) {
if (combined[change.newIndex]?.doc.ref.isEqual(change.doc.ref)) {
// Not sure why the duplicates are getting fired
} else {
return sliceAndSplice(combined, change.newIndex, 0, change);
Expand All @@ -119,7 +119,7 @@ export function combineChange<T>(combined: DocumentChange<T>[], change: Document
}
break;
case 'removed':
if (combined[change.oldIndex] && combined[change.oldIndex].doc.ref.isEqual(change.doc.ref)) {
if (combined[change.oldIndex]?.doc.ref.isEqual(change.doc.ref)) {
return sliceAndSplice(combined, change.oldIndex, 1);
}
break;
Expand Down
12 changes: 6 additions & 6 deletions src/database/rxfire.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions src/firestore/lite/rxfire.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions src/firestore/rxfire.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/performance/rxfire.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions src/remote-config/rxfire.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/vertexai-preview/firebase.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading