Skip to content

WIP Rxjs 6 and angular 6 #1582

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

Closed
wants to merge 9 commits into from
Closed
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: 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
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
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-rc.5",
"@angular/compiler": "^6.0.0-rc.5",
"@angular/core": "^6.0.0-rc.5",
"@angular/platform-browser": "^6.0.0-rc.5",
"@angular/platform-browser-dynamic": "^6.0.0-rc.5",
"@firebase/app": "^0.1.6",
"@firebase/app-types": "^0.1.1",
"@firebase/auth": "^0.3.2",
Expand All @@ -47,15 +47,16 @@
"@firebase/storage-types": "^0.1.1",
"bufferutil": "^3.0.3",
"firebase": "^4.8.2",
"rxjs": "^5.5.4",
"rxjs": "^6.0.0",
"rxjs-compat": "^6.0.0",
"utf-8-validate": "^4.0.0",
"ws": "^3.3.2",
"xmlhttprequest": "^1.8.0",
"zone.js": "^0.8.0"
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular/compiler-cli": "^5.0.0",
"@angular/platform-server": "^5.0.0",
"@angular/compiler-cli": "^6.0.0-rc.5",
"@angular/platform-server": "^6.0.0-rc.5",
"@types/jasmine": "^2.5.36",
"@types/request": "0.0.30",
"concurrently": "^2.2.0",
Expand Down Expand Up @@ -90,7 +91,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"
}
10 changes: 4 additions & 6 deletions src/auth/auth.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { User } from '@firebase/auth-types';
import { ReflectiveInjector, Provider } from '@angular/core';
import { Observable } from 'rxjs/Observable'
import { Subject } from 'rxjs/Subject'
import { Observer } from 'rxjs/Observer';
import { Observable , Subject , Observer } from 'rxjs'
import { TestBed, inject } from '@angular/core/testing';
import { _do } from 'rxjs/operator/do';
import { take } from 'rxjs/operator/take';
import { skip } from 'rxjs/operator/skip';



import { FirebaseApp, FirebaseAppConfig, AngularFireModule, FirebaseAppName } from 'angularfire2';
import { AngularFireAuth, AngularFireAuthModule } from 'angularfire2/auth';
import { COMMON_CONFIG } from './test-config';
Expand Down
19 changes: 11 additions & 8 deletions src/auth/auth.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@

import {of as observableOf, from as observableFrom, Observable } from 'rxjs';

import {switchMap} from 'rxjs/operators';
import { FirebaseAuth, User } from '@firebase/auth-types';
import { FirebaseOptions } from '@firebase/app-types';
import { Injectable, Inject, Optional, NgZone } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { observeOn } from 'rxjs/operator/observeOn';


import { FirebaseAppConfig, FirebaseAppName, _firebaseAppFactory, FirebaseZoneScheduler } from 'angularfire2';

import 'rxjs/add/operator/switchMap';
import 'rxjs/add/observable/of';
import 'rxjs/add/observable/fromPromise';




@Injectable()
export class AngularFireAuth {
Expand Down Expand Up @@ -55,9 +58,9 @@ export class AngularFireAuth {
return { unsubscribe };
})
)
).switchMap((user:User|null) => {
return user ? Observable.fromPromise(user.getIdToken()) : Observable.of(null)
});
).pipe(switchMap((user:User) => {
return user ? observableFrom(user.getIdToken()) : observableOf(null)
}));

}

Expand Down
2 changes: 1 addition & 1 deletion src/core/angularfire2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Reference } from '@firebase/database-types';
import { TestBed, inject, withModule, async } from '@angular/core/testing';
import { ReflectiveInjector, Provider, PlatformRef, NgModule, Compiler, ApplicationRef, CompilerFactory } from '@angular/core';
import { FirebaseApp, FirebaseAppConfig, AngularFireModule } from 'angularfire2';
import { Subscription } from 'rxjs/Subscription';
import { Subscription } from 'rxjs';
import { COMMON_CONFIG } from './test-config';
import { BrowserModule } from '@angular/platform-browser';

Expand Down
14 changes: 7 additions & 7 deletions src/core/angularfire2.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@

import {first} from 'rxjs/operators';
import { InjectionToken, NgZone } from '@angular/core';
import { Subscription } from 'rxjs/Subscription';
import { Observable } from 'rxjs/Observable';
import { Subscription , Observable , Subscriber } from 'rxjs';
import { observeOn } from 'rxjs/operators';
import { queue } from 'rxjs/scheduler/queue';

import firebase from '@firebase/app';
import { FirebaseApp, FirebaseOptions } from '@firebase/app-types';

import 'zone.js';
import 'rxjs/add/operator/first';
import { Subscriber } from 'rxjs/Subscriber';
import { observeOn } from 'rxjs/operator/observeOn';


export const FirebaseAppName = new InjectionToken<string>('angularfire2.appName');
export const FirebaseAppConfig = new InjectionToken<FirebaseOptions>('angularfire2.config');
Expand All @@ -27,7 +27,7 @@ export class FirebaseZoneScheduler {
return new Observable<T>(subscriber => {
const noop = () => {};
const task = Zone.current.scheduleMacroTask('firebaseZoneBlock', noop, {}, noop, noop);
obs$.first().subscribe(() => this.zone.runOutsideAngular(() => task.invoke()));
obs$.pipe(first()).subscribe(() => this.zone.runOutsideAngular(() => task.invoke()));
return obs$.subscribe(subscriber);
});
}
Expand All @@ -37,6 +37,6 @@ export class FirebaseZoneScheduler {
return obs$.subscribe(subscriber);
});
});
return observeOn.call(outsideAngular, this);
return outsideAngular;
}
}
24 changes: 13 additions & 11 deletions src/database-deprecated/firebase_list_factory.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

import {skip, filter} from 'rxjs/operators';
import { DataSnapshot } from '@firebase/database-types';
import { FirebaseApp, FirebaseAppConfig, AngularFireModule} from 'angularfire2';
import { AngularFireDatabase, AngularFireDatabaseModule, FirebaseListObservable,
Expand All @@ -9,12 +11,12 @@ import * as utils from './utils';
import { Query, AFUnwrappedDataSnapshot } from './interfaces';
import { Subscription, Observable, Subject } from 'rxjs';
import { COMMON_CONFIG } from './test-config';
import { _do } from 'rxjs/operator/do';
import { map } from 'rxjs/operator/map';
import { skip } from 'rxjs/operator/skip';
import { take } from 'rxjs/operator/take';
import { toArray } from 'rxjs/operator/toArray';
import { toPromise } from 'rxjs/operator/toPromise';







const questionsPath = 'questions';

Expand Down Expand Up @@ -682,10 +684,10 @@ describe('FirebaseListFactory', () => {
})
.run(() => {
// Creating a new observable so that the current zone is captured.
subscription = FirebaseListFactory(app.database().ref(`questions`))
.filter(d => d
subscription = FirebaseListFactory(app.database().ref(`questions`)).pipe(
filter(d => d
.map((v: any) => v.$value)
.indexOf('in-the-zone') > -1)
.indexOf('in-the-zone') > -1))
.subscribe(data => {
expect(Zone.current.name).toBe('newZone');
done();
Expand All @@ -709,8 +711,8 @@ describe('FirebaseListFactory', () => {
let keyToRemove: string;

afterEach((done: any) => {
subscription = questions
.skip(2)
subscription = questions.pipe(
skip(2))
.take(1)
.subscribe((items: any[]) => {
expect(items.length).toBe(3);
Expand Down
9 changes: 5 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,13 @@ 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 { switchMap, map, observeOn } 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
4 changes: 2 additions & 2 deletions src/database-deprecated/firebase_list_observable.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FirebaseApp, FirebaseAppConfig, AngularFireModule} from 'angularfire2';
import { AngularFireDatabase, AngularFireDatabaseModule, FirebaseListObservable, FirebaseObjectFactory } from 'angularfire2/database-deprecated';
import { Observer } from 'rxjs/Observer';
import { map } from 'rxjs/operator/map';
import { Observer } from 'rxjs';

import { FirebaseApp as FBApp } from '@firebase/app-types';
import { DataSnapshot, Reference } from '@firebase/database-types';
import { unwrapMapFn } from './utils';
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
6 changes: 4 additions & 2 deletions src/database-deprecated/firebase_object_factory.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

import {filter} from 'rxjs/operators';
import { FirebaseApp as FBApp } from '@firebase/app-types';
import { Reference } from '@firebase/database-types';
import { Subscription } from 'rxjs';
Expand Down Expand Up @@ -132,8 +134,8 @@ describe('FirebaseObjectFactory', () => {
})
.run(() => {
// Creating a new observable so that the current zone is captured.
subscription = FirebaseObjectFactory(app.database().ref(`questions/${i}`))
.filter(d => d.$value === 'in-the-zone')
subscription = FirebaseObjectFactory(app.database().ref(`questions/${i}`)).pipe(
filter(d => d.$value === 'in-the-zone'))
.subscribe(data => {
expect(Zone.current.name).toBe('newZone');
done();
Expand Down
5 changes: 3 additions & 2 deletions src/database-deprecated/firebase_object_factory.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
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
4 changes: 2 additions & 2 deletions src/database-deprecated/firebase_object_observable.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { TestBed, inject } from '@angular/core/testing';
import { FirebaseApp, FirebaseAppConfig, AngularFireModule } from 'angularfire2';
import { COMMON_CONFIG } from './test-config';
import { AngularFireDatabase, AngularFireDatabaseModule, FirebaseObjectObservable } from 'angularfire2/database-deprecated';
import { Observer } from 'rxjs/Observer';
import { map } from 'rxjs/operator/map';
import { Observer } from 'rxjs';

import { FirebaseApp as FBApp } from '@firebase/app-types';
import { Reference } from '@firebase/database-types';

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
4 changes: 1 addition & 3 deletions src/database-deprecated/query_observable.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Observable } from 'rxjs/Observable';
import { Observer } from 'rxjs/Observer';
import { Subject } from 'rxjs/Subject';
import { Observable , Observer , Subject } from 'rxjs';
import { Query, ScalarQuery } from './interfaces';
import { getOrderObservables, observeQuery } from 'angularfire2/database-deprecated';

Expand Down
12 changes: 4 additions & 8 deletions src/database-deprecated/query_observable.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
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, combineLatest } from 'rxjs';
import { auditTime, merge, map } from 'rxjs/operators';


import { Query, ScalarQuery, OrderByOptions, OrderBySelection, LimitToOptions, LimitToSelection, Primitive } from './interfaces';
import { hasKey, isNil } from './utils';

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

Expand Down
2 changes: 1 addition & 1 deletion src/database/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Reference, DataSnapshot, ThenableReference, Query } from '@firebase/database-types';
import { Observable } from 'rxjs/Observable';
import { Observable } from 'rxjs';

export type FirebaseOperation = string | Reference | DataSnapshot;

Expand Down
6 changes: 4 additions & 2 deletions src/database/list/audit-trail.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@

import {skip} from 'rxjs/operators';
import { Reference } from '@firebase/database-types';
import { FirebaseApp, FirebaseAppConfig, AngularFireModule } from 'angularfire2';
import { AngularFireDatabase, AngularFireDatabaseModule, auditTrail, ChildEvent } from 'angularfire2/database';
import { TestBed, inject } from '@angular/core/testing';
import { COMMON_CONFIG } from '../test-config';
import 'rxjs/add/operator/skip';


// generate random string to test fidelity of naming
const rando = () => (Math.random() + 1).toString(36).substring(7);
Expand Down Expand Up @@ -47,7 +49,7 @@ describe('auditTrail', () => {
aref.set(batch);
const changes = auditTrail(aref, events);
return {
changes: changes.skip(skip),
changes: changes.pipe(skip(skip)),
ref: aref
};
}
Expand Down
Loading