Skip to content

feat(): support Angular and rxjs 6 #1625

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

Merged
merged 7 commits into from
May 14, 2018
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
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ script:
- ./node_modules/.bin/karma start --single-run --browsers ChromeHeadlessTravis --reporters mocha
# Run integration test to make sure our typings are correct for user-land.
- node tools/run-typings-test.js
# Run the ng6 build test
- cd test/ng-build/ng6 && yarn && yarn build:prod
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
<a name="5.0.0-rc.8"></a>
# [5.0.0-rc.8](https://github.com/angular/angularfire2/compare/5.0.0-rc.7...5.0.0-rc.8) (2018-05-12)

### Bug Fixes

* Zone was already loaded, type is implied ([#1631](https://github.com/angular/angularfire2/issues/1631)) ([7d2fd53](https://github.com/angular/angularfire2/commit/7d2fd53)), closes [#1599](https://github.com/angular/angularfire2/issues/1599)

### Features

* Supporting Angular and rxjs 6 ([dd4a36c](https://github.com/angular/angularfire2/commit/dd4a36c))
* Support Firebase JS SDK 5.0 ([#1628](https://github.com/angular/angularfire2/issues/1628)) ([b99bfa3](https://github.com/angular/angularfire2/commit/b99bfa3))
* Support FirebaseAppConfig, clean up injection tokens ([#1627](https://github.com/angular/angularfire2/issues/1627)) ([57906bd](https://github.com/angular/angularfire2/commit/57906bd))
* **firestore:** Support Firestore Settings, timestampsInSnapshots default to true ([#1629](https://github.com/angular/angularfire2/issues/1629)) ([570c0a7](https://github.com/angular/angularfire2/commit/570c0a7))
* **auth:** Update to rxjs pipeable operators ([#1621](https://github.com/angular/angularfire2/issues/1621)) ([0c3b215](https://github.com/angular/angularfire2/commit/0c3b215))
* **core:** Update to rxjs pipeable operators ([#1620](https://github.com/angular/angularfire2/issues/1620)) ([3fbbb7d](https://github.com/angular/angularfire2/commit/3fbbb7d))
* **database:** Update to rxjs pipeable operators ([#1622](https://github.com/angular/angularfire2/issues/1622)) ([5c3681d](https://github.com/angular/angularfire2/commit/5c3681d))
* **firestore:** Update to rxjs pipeable operators ([#1623](https://github.com/angular/angularfire2/issues/1623)) ([97b26e3](https://github.com/angular/angularfire2/commit/97b26e3))
* **storage:** Update to rxjs pipeable operators ([#1624](https://github.com/angular/angularfire2/issues/1624)) ([014be21](https://github.com/angular/angularfire2/commit/014be21))

### Breaking changes

* Due to the addition of a conflicting `FirebaseAppConfig` interface in Firebase 4.13 we've now changed our `FirebaseAppConfig` Injection Token to be `FirebaseOptionsToken`
* For consistency the `FirebaseAppName` Injection Token is now `FirebaseAppNameToken`
* rxjs 5 is no longer supported, upgrade to 6 ([see the rxjs migration guide for more information](https://github.com/ReactiveX/rxjs/blob/master/MIGRATION.md))
* Firebase JS SDK 4.x is no longer supported, upgrade to 5 ([see the changelog for more information](https://firebase.google.com/support/release-notes/js#version_500_may_8_2018))

<a name="5.0.0-rc.7"></a>
# [5.0.0-rc.7](https://github.com/angular/angularfire2/compare/5.0.0-rc.6...5.0.0-rc.7) (2018-05-04)

Expand Down
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = function(config) {
'node_modules/zone.js/dist/async-test.js',
'node_modules/zone.js/dist/fake-async-test.js',

'node_modules/rxjs/bundles/Rx.{js,map}',
'node_modules/rxjs/bundles/rxjs.umd.{js,map}',

...getAngularFiles(['core','common','compiler','platform-browser','platform-browser-dynamic']),

Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angularfire2",
"version": "5.0.0-rc.7",
"version": "5.0.0-rc.8",
"description": "The official library of Firebase and Angular.",
"private": true,
"scripts": {
Expand Down Expand Up @@ -29,11 +29,11 @@
},
"homepage": "https://github.com/angular/angularfire2#readme",
"dependencies": {
"@angular/common": "^5.0.0",
"@angular/compiler": "^5.0.0",
"@angular/core": "^5.0.0",
"@angular/platform-browser": "^5.0.0",
"@angular/platform-browser-dynamic": "^5.0.0",
"@angular/common": "^6.0.0",
"@angular/compiler": "^6.0.0",
"@angular/core": "^6.0.0",
"@angular/platform-browser": "^6.0.0",
"@angular/platform-browser-dynamic": "^6.0.0",
"@firebase/app": "^0.3.1",
"@firebase/app-types": "^0.3.1",
"@firebase/auth": "^0.5.2",
Expand All @@ -47,15 +47,15 @@
"@firebase/storage-types": "^0.2.2",
"bufferutil": "^3.0.3",
"firebase": "^5.0.2",
"rxjs": "^5.5.4",
"rxjs": "^6.0.0",
"utf-8-validate": "^4.0.0",
"ws": "^3.3.2",
"xmlhttprequest": "^1.8.0",
"zone.js": "^0.8.0"
},
"devDependencies": {
"@angular/compiler-cli": "^5.0.0",
"@angular/platform-server": "^5.0.0",
"@angular/compiler-cli": "^6.0.0",
"@angular/platform-server": "^6.0.0",
"@types/jasmine": "^2.5.36",
"@types/request": "0.0.30",
"concurrently": "^2.2.0",
Expand Down Expand Up @@ -90,7 +90,7 @@
"systemjs": "^0.19.16",
"systemjs-builder": "^0.15.7",
"traceur": "0.0.96",
"typescript": ">=2.4.2 <2.5"
"typescript": ">=2.7.2 <2.8.0"
},
"typings": "index.d.ts"
}
4 changes: 1 addition & 3 deletions src/auth/auth.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { FirebaseAuth, User } from '@firebase/auth-types';
import { FirebaseOptions, FirebaseAppConfig } from '@firebase/app-types';
import { Injectable, Inject, Optional, NgZone, PLATFORM_ID } from '@angular/core';
import { Observable } from 'rxjs';
import { Observable, of, from } from 'rxjs';
import { switchMap } from 'rxjs/operators';
import { of } from 'rxjs/observable/of';
import { from } from 'rxjs/observable/from';

import { FirebaseOptionsToken, FirebaseAppConfigToken, FirebaseAppNameToken, _firebaseAppFactory, FirebaseZoneScheduler } from 'angularfire2';

Expand Down
3 changes: 1 addition & 2 deletions src/core/angularfire2.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { InjectionToken, NgZone } from '@angular/core';
import { isPlatformServer } from '@angular/common';
import { Observable, Subscription } from 'rxjs';
import { queue } from 'rxjs/scheduler/queue';
import { Observable, Subscription, queueScheduler as queue } from 'rxjs';
import { first } from 'rxjs/operators';

import firebase from '@firebase/app';
Expand Down
2 changes: 1 addition & 1 deletion src/database-deprecated/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class AngularFireDatabase {
zone: NgZone
) {
this.database = zone.runOutsideAngular(() => {
const app = _firebaseAppFactory(config, name);
const app = _firebaseAppFactory(options, name, config);
return app.database(databaseURL || undefined);
});
}
Expand Down
6 changes: 2 additions & 4 deletions src/database-deprecated/firebase_list_factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import { FirebaseZoneScheduler } from 'angularfire2';
import * as utils from './utils';
import { AFUnwrappedDataSnapshot } from './interfaces';
import { FirebaseListObservable } from './firebase_list_observable';
import { Observer } from 'rxjs/Observer';
import { observeOn } from 'rxjs/operator/observeOn';
import { Observer } from 'rxjs';
import { observeOn, switchMap, map } from 'rxjs/operators';
import { observeQuery } from './query_observable';
import { Query, FirebaseListFactoryOpts, DatabaseReference, DatabaseQuery, DatabaseSnapshot } from './interfaces';
import { switchMap } from 'rxjs/operator/switchMap';
import { map } from 'rxjs/operator/map';

export function FirebaseListFactory (
ref: DatabaseReference,
Expand Down
5 changes: 1 addition & 4 deletions src/database-deprecated/firebase_list_observable.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { Observable } from 'rxjs/Observable';
import { Operator } from 'rxjs/Operator';
import { Subscriber } from 'rxjs/Subscriber';
import { Subscription } from 'rxjs/Subscription';
import { Observable, Operator, Subscriber, Subscription } from 'rxjs';
import { Reference, DataSnapshot, ThenableReference } from '@firebase/database-types';
import * as utils from './utils';
import { AFUnwrappedDataSnapshot, FirebaseOperationCases, QueryReference, DatabaseSnapshot, DatabaseReference } from './interfaces';
Expand Down
4 changes: 2 additions & 2 deletions src/database-deprecated/firebase_object_factory.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { NgZone } from '@angular/core';
import { FirebaseObjectObservable } from './firebase_object_observable';
import { FirebaseZoneScheduler } from 'angularfire2';
import { Observer } from 'rxjs/Observer';
import { observeOn } from 'rxjs/operator/observeOn';
import { Observer } from 'rxjs';
import { observeOn } from 'rxjs/operators';
import { DataSnapshot } from '@firebase/database-types';
import * as utils from './utils';
import { FirebaseObjectFactoryOpts, DatabaseReference } from './interfaces';
Expand Down
5 changes: 1 addition & 4 deletions src/database-deprecated/firebase_object_observable.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { Observable } from 'rxjs/Observable';
import { Operator } from 'rxjs/Operator';
import { Subscriber } from 'rxjs/Subscriber';
import { Subscription } from 'rxjs/Subscription';
import { Observable, Operator, Subscriber, Subscription } from 'rxjs';
import { Reference } from '@firebase/database-types';

export class FirebaseObjectObservable<T> extends Observable<T> {
Expand Down
2 changes: 1 addition & 1 deletion src/database-deprecated/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Observable } from 'rxjs/Observable';
import { Observable } from 'rxjs';
import { Reference, DataSnapshot, Query } from '@firebase/database-types';

export interface FirebaseOperationCases {
Expand Down
10 changes: 2 additions & 8 deletions src/database-deprecated/query_observable.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import { Observable } from 'rxjs/Observable';
import { of as observableOf } from 'rxjs/observable/of';
import { Operator } from 'rxjs/Operator';
import { Observer } from 'rxjs/Observer';
import { combineLatest } from 'rxjs/operator/combineLatest';
import { merge } from 'rxjs/operator/merge';
import { map } from 'rxjs/operator/map';
import { auditTime } from 'rxjs/operator/auditTime';
import { Observable, of as observableOf, Operator, Observer } from 'rxjs';
import { auditTime, combineLatest, merge, map } from 'rxjs/operators';
import { Query, ScalarQuery, OrderByOptions, OrderBySelection, LimitToOptions, LimitToSelection, Primitive } from './interfaces';
import { hasKey, isNil } from './utils';

Expand Down
4 changes: 1 addition & 3 deletions src/database-deprecated/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { DataSnapshot, FirebaseDatabase } from '@firebase/database-types';
import { Subscription } from 'rxjs/Subscription';
import { Scheduler } from 'rxjs/Scheduler';
import { queue } from 'rxjs/scheduler/queue';
import { Subscription, Scheduler, queueScheduler as queue } from 'rxjs';
import { AFUnwrappedDataSnapshot, PathReference, DatabaseReference } from './interfaces';

const REGEX_ABSOLUTE_URL = /^[a-z]+:\/\/.*/;
Expand Down
4 changes: 1 addition & 3 deletions src/database/list/changes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { fromRef } from '../observable/fromRef';
import { Observable } from 'rxjs';
import { of } from 'rxjs/observable/of';
import { merge } from 'rxjs/observable/merge';
import { Observable, of, merge } from 'rxjs';

import { DatabaseQuery, ChildEvent, AngularFireAction, SnapshotAction } from '../interfaces';
import { isNil } from '../utils';
Expand Down
2 changes: 1 addition & 1 deletion src/database/list/snapshot-changes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('snapshotChanges', () => {

it('should listen to all events by default', (done) => {
const { snapChanges, ref } = prepareSnapshotChanges();
snapChanges.take(1).subscribe(actions => {
snapChanges.pipe(take(1)).subscribe(actions => {
const data = actions.map(a => a.payload!.val());
expect(data).toEqual(items);
}).add(done);
Expand Down
3 changes: 1 addition & 2 deletions src/database/list/state-changes.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { DatabaseQuery, ChildEvent, AngularFireAction, SnapshotAction } from '../interfaces';
import { fromRef } from '../observable/fromRef';
import { validateEventsArray } from './utils';
import { Observable } from 'rxjs';
import { merge } from 'rxjs/observable/merge';
import { Observable, merge } from 'rxjs';

import { DataSnapshot } from '@firebase/database-types';
import { AngularFireDatabase } from '../database';
Expand Down
1 change: 0 additions & 1 deletion src/database/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Subscription, Scheduler } from 'rxjs';
import { queue } from 'rxjs/scheduler/queue';
import { PathReference, DatabaseReference, FirebaseOperation, FirebaseOperationCases } from './interfaces';
import { FirebaseDatabase } from '@firebase/database-types';

Expand Down
4 changes: 2 additions & 2 deletions src/firestore/collection/collection.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DocumentChangeType, CollectionReference, Query, DocumentReference } from '@firebase/firestore-types';
import { Observable, Subscriber } from 'rxjs';
import { fromCollectionRef } from '../observable/fromRef';
import { map, filter } from 'rxjs/operators';
import { map, filter, scan } from 'rxjs/operators';

import { Injectable } from '@angular/core';

Expand Down Expand Up @@ -87,7 +87,7 @@ export class AngularFirestoreCollection<T> {
* @param events
*/
auditTrail(events?: DocumentChangeType[]): Observable<DocumentChangeAction[]> {
return this.stateChanges(events).scan((current, action) => [...current, ...action], []);
return this.stateChanges(events).pipe(scan((current, action) => [...current, ...action], []));
}

/**
Expand Down
9 changes: 3 additions & 6 deletions src/firestore/firestore.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { InjectionToken, NgZone, PLATFORM_ID } from '@angular/core';
import { InjectionToken, NgZone, PLATFORM_ID, Injectable, Inject, Optional } from '@angular/core';
import { FirebaseFirestore, CollectionReference, DocumentReference, Settings } from '@firebase/firestore-types';

import { Observable, Subscriber } from 'rxjs';
import { Observable, Subscriber, of, from } from 'rxjs';
import { map, catchError } from 'rxjs/operators';
import { of } from 'rxjs/observable/of';
import { from } from 'rxjs/observable/from';
import { FirebaseOptions, FirebaseAppConfig } from '@firebase/app-types';
import { Injectable, Inject, Optional } from '@angular/core';

import { QueryFn, AssociatedReference } from './interfaces';
import { AngularFirestoreDocument } from './document/document';
Expand Down Expand Up @@ -118,7 +115,7 @@ export class AngularFirestore {
) {
this.scheduler = new FirebaseZoneScheduler(zone, platformId);
this.firestore = zone.runOutsideAngular(() => {
const app = _firebaseAppFactory(config, name);
const app = _firebaseAppFactory(options, name, config);
const firestore = app.firestore();
firestore.settings(settings || DefaultFirestoreSettings);
return firestore;
Expand Down
7 changes: 3 additions & 4 deletions src/storage/ref.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { SettableMetadata, UploadMetadata, Reference, StringFormat } from '@firebase/storage-types';
import { createUploadTask, AngularFireUploadTask } from './task';
import { Observable } from 'rxjs';
import { from } from 'rxjs/observable/from';
import { Observable, from } from 'rxjs';
import { FirebaseZoneScheduler } from 'angularfire2';

export interface AngularFireStorageReference {
Expand Down Expand Up @@ -31,9 +30,9 @@ export function createStorageRef(ref: Reference, scheduler: FirebaseZoneSchedule
from(ref.getMetadata())
)
),
delete: () => Observable.from(ref.delete()),
delete: () => from(ref.delete()),
child: (path: string) => createStorageRef(ref.child(path), scheduler),
updateMetatdata: (meta: SettableMetadata) => Observable.from(ref.updateMetadata(meta)),
updateMetatdata: (meta: SettableMetadata) => from(ref.updateMetadata(meta)),
put: (data: any, metadata?: UploadMetadata) => {
const task = ref.put(data, metadata);
return createUploadTask(task);
Expand Down
3 changes: 1 addition & 2 deletions src/storage/storage.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Observable } from 'rxjs'
import { forkJoin } from 'rxjs/observable/forkJoin';
import { Observable, forkJoin } from 'rxjs'
import { map, mergeMap, tap } from 'rxjs/operators';
import { TestBed, inject } from '@angular/core/testing';
import { FirebaseApp, FirebaseOptionsToken, AngularFireModule, FirebaseAppNameToken } from 'angularfire2';
Expand Down
3 changes: 1 addition & 2 deletions src/storage/task.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { UploadTaskSnapshot, UploadTask } from '@firebase/storage-types';
import { fromTask } from './observable/fromTask';
import { Observable } from 'rxjs';
import { Observable, from } from 'rxjs';
import { map, filter } from 'rxjs/operators';
import { from } from 'rxjs/observable/from';

export interface AngularFireUploadTask {
task: UploadTask,
Expand Down
2 changes: 1 addition & 1 deletion test/ng-build/build.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cd ng5 && ng build --prod
cd ng6 && ng build --prod
6 changes: 3 additions & 3 deletions test/ng-build/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require('fs');
const { spawn, spawnSync } = require('child_process');
const ng5Pkg = require(`${__dirname}/ng5/package.json`);
const ng5Pkg = require(`${__dirname}/ng6/package.json`);
const pkg = require('../../package.json');
const shell = require('shelljs');

Expand All @@ -11,7 +11,7 @@ function packageAngularFire() {
const res = spawnSync('sh', ['pack.sh']);
console.log(`------------ FINISHED PACKAGING VERSION ${PACKAGED_VERSION} ------------`);
console.log(`------------ INSTALLING VERSION ${PACKAGED_VERSION} ------------`);
if (shell.exec(`cd ng5 && npm i firebase ../${PACKAGED_VERSION}`).code !== 0) {
if (shell.exec(`cd ng5 && yarn add firebase ../${PACKAGED_VERSION}`).code !== 0) {
shell.echo('Error');
shell.exit(1);
}
Expand All @@ -30,7 +30,7 @@ function buildVersion5() {
});
cmd.on('close', () => {
try {
const dir = fs.readdirSync(__dirname + '/ng5/dist');
const dir = fs.readdirSync(__dirname + '/ng6/dist');
console.log(dir);
console.log(`------------ SUCCESS VERSION ${ng5Pkg.dependencies['@angular/core']} ------------`);
} catch (e) {
Expand Down
35 changes: 0 additions & 35 deletions test/ng-build/ng5/package.json

This file was deleted.

Loading