Skip to content

Commit 4642089

Browse files
committed
refactor(db): create push id method
1 parent b99f22a commit 4642089

File tree

3 files changed

+6
-19
lines changed

3 files changed

+6
-19
lines changed

src/database/database.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ export class AngularFireDatabase {
2929
return createObjectReference<T>(ref);
3030
}
3131

32+
createPushId() {
33+
return this.database.ref().push().key;
34+
}
35+
3236
}
3337

3438
export {

src/database/list/changes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { fromRef } from '../observable/fromRef';
22
import { Observable } from 'rxjs/Observable';
3-
import { DatabaseQuery, ChildEvent, SnapshotChange, AngularFireAction} from '../interfaces';
3+
import { DatabaseQuery, ChildEvent, SnapshotChange, AngularFireAction, SnapshotAction } from '../interfaces';
44
import { positionFor, positionAfter } from './utils';
55
import 'rxjs/add/operator/scan';
66
import 'rxjs/add/observable/merge';
77

88
// TODO(davideast): check safety of ! operator in scan
9-
export function listChanges<T>(ref: DatabaseQuery, events: ChildEvent[]): Observable<AngularFireAction<any>[]> {
9+
export function listChanges<T>(ref: DatabaseQuery, events: ChildEvent[]): Observable<SnapshotAction[]> {
1010
const childEvent$ = events.map(event => fromRef(ref, event));
1111
return Observable.merge(...childEvent$)
1212
.scan((current, action) => {

src/database/list/state-changes.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,6 @@ import { database } from 'firebase/app';
66
import 'rxjs/add/observable/merge';
77
import 'rxjs/add/operator/scan';
88

9-
/**
10-
* NOTES FOR LATER:
11-
* Consider have snapshotChanges() return a SnapshotAction because it
12-
* retains the event information.
13-
*
14-
* Consider having valueChanges(), snapshotChanges(), and stateChanges()
15-
* return an Action. For snapshotChanges it would be an
16-
* Action<SnapshotPrevKey> and for valueChanges it would be an Action<T>.
17-
*
18-
* Consider providing the delta changes for both valueChanges() and
19-
* snapshotChanges().
20-
*
21-
* Consider providing an auditTrail() method that scans over stateChanges()
22-
* to provide each action as an array at that occurred at that location. This
23-
* would be a loaded dataset.
24-
*/
25-
269
export function createStateChanges(query: DatabaseQuery) {
2710
return (events?: ChildEvent[]) => stateChanges(query, events);
2811
}

0 commit comments

Comments
 (0)