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 './';
|
2018-02-14 13:00:19 +00:00
|
|
|
import type { NativeDocumentChange } 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;
|
2018-06-17 15:35:02 +00:00
|
|
|
_type: 'added' | 'modified' | 'removed';
|
2017-09-26 13:57:25 +00:00
|
|
|
|
2018-02-14 13:00:19 +00:00
|
|
|
constructor(firestore: Firestore, nativeData: NativeDocumentChange) {
|
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;
|
|
|
|
}
|
|
|
|
}
|