Skip to content

Commit

Permalink
refactor: remove usage of 'self'
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidt-sebastian committed Jan 14, 2020
1 parent 82273ec commit 4d4082e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
13 changes: 6 additions & 7 deletions dev/src/index.ts
Expand Up @@ -898,10 +898,8 @@ export class Firestore {
request.mask = {fieldPaths};
}

const self = this;
return self
.requestStream('batchGetDocuments', request, requestTag)
.then(stream => {
return this.requestStream('batchGetDocuments', request, requestTag).then(
stream => {
return new Promise<Array<DocumentSnapshot<T>>>((resolve, reject) => {
stream
.on('error', err => {
Expand All @@ -924,15 +922,15 @@ export class Firestore {
'Received document: %s',
response.found.name!
);
document = self.snapshot_(response.found, response.readTime!);
document = this.snapshot_(response.found, response.readTime!);
} else {
logger(
'Firestore.getAll_',
requestTag,
'Document missing: %s',
response.missing!
);
document = self.snapshot_(
document = this.snapshot_(
response.missing!,
response.readTime!
);
Expand Down Expand Up @@ -983,7 +981,8 @@ export class Firestore {
});
stream.resume();
});
});
}
);
}

/**
Expand Down
5 changes: 1 addition & 4 deletions dev/src/reference.ts
Expand Up @@ -1747,14 +1747,12 @@ export class Query<T = DocumentData> {
* @param {bytes=} transactionId A transaction ID.
*/
_get(transactionId?: Uint8Array): Promise<QuerySnapshot<T>> {
const self = this;
const docs: Array<QueryDocumentSnapshot<T>> = [];

return new Promise((resolve, reject) => {
let readTime: Timestamp;

self
._stream(transactionId)
this._stream(transactionId)
.on('error', err => {
reject(err);
})
Expand Down Expand Up @@ -1933,7 +1931,6 @@ export class Query<T = DocumentData> {
} else {
this.push({readTime});
}
callback();
});

this.firestore.initializeIfNeeded(tag).then(() => {
Expand Down
4 changes: 2 additions & 2 deletions dev/src/transaction.ts
Expand Up @@ -417,8 +417,6 @@ export class Transaction {
);
}

await this.begin();

try {
const promise = updateFunction(this);
if (!(promise instanceof Promise)) {
Expand All @@ -438,6 +436,8 @@ export class Transaction {
return Promise.reject(err); // User callback failed
}

await this.begin();

try {
await this.commit();
return result; // Success
Expand Down

0 comments on commit 4d4082e

Please sign in to comment.