2017-09-26 13:57:25 +00:00
|
|
|
/**
|
|
|
|
* @flow
|
|
|
|
* DocumentChange representation wrapper
|
|
|
|
*/
|
2017-11-17 14:22:46 +00:00
|
|
|
import DocumentSnapshot from './DocumentSnapshot';
|
2017-11-17 11:07:52 +00:00
|
|
|
|
|
|
|
import type Firestore from './';
|
2017-11-23 17:29:40 +00:00
|
|
|
import type { FirestoreNativeDocumentChange } from '../../types';
|
2017-09-26 13:57:25 +00:00
|
|
|
|
2017-11-17 11:07:52 +00:00
|
|
|
/**
|
2017-09-26 13:57:25 +00:00
|
|
|
* @class DocumentChange
|
|
|
|
*/
|
|
|
|
export default class DocumentChange {
|
|
|
|
_document: DocumentSnapshot;
|
|
|
|
_newIndex: number;
|
|
|
|
_oldIndex: number;
|
|
|
|
_type: string;
|
|
|
|
|
2017-11-17 14:22:46 +00:00
|
|
|
constructor(firestore: Firestore, nativeData: FirestoreNativeDocumentChange) {
|
2017-10-10 16:48:53 +00:00
|
|
|
this._document = new DocumentSnapshot(firestore, nativeData.document);
|
2017-09-26 13:57:25 +00:00
|
|
|
this._newIndex = nativeData.newIndex;
|
|
|
|
this._oldIndex = nativeData.oldIndex;
|
|
|
|
this._type = nativeData.type;
|
|
|
|
}
|
|
|
|
|
|
|
|
get doc(): DocumentSnapshot {
|
|
|
|
return this._document;
|
|
|
|
}
|
|
|
|
|
|
|
|
get newIndex(): number {
|
|
|
|
return this._newIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
get oldIndex(): number {
|
|
|
|
return this._oldIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
get type(): string {
|
|
|
|
return this._type;
|
|
|
|
}
|
|
|
|
}
|