-
Notifications
You must be signed in to change notification settings - Fork 900
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
refactor(database): classes for typescript database implementation #55
refactor(database): classes for typescript database implementation #55
Conversation
); | ||
} else { | ||
// Exact match on each key. | ||
return this.callbacks_.every(<any>function (cb, eventType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jshcrowthe is the SDK using some library that adds the every
method to Object.prototype
? Otherwise, this looks like a bug to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case it is indeed a bug, we could add this function to src/utils/obj.ts
:
export const every = function(obj, fn) {
for (let key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
if (!fn(key, obj[key])) {
return false;
}
}
}
return true;
};
and then replace this block of code with:
return every(this.callbacks_, (eventType, cb) => other.callbacks_[eventType] === cb);
Let me know! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm reviewing this at 3 AM but triggering this code proves you right. If we can add the helper fxn and update that block that'd be fantastic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Josh, go get some sleep!
I'll update this as soon as I get home :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
ff6727c
to
1e51f99
Compare
CLAs look good, thanks! |
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that they're okay with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
I think I just offended the Git gods somehow... let me try to fix this. Edit: phew, we're back on track. |
CLAs look good, thanks! |
327ee91
to
9afcadf
Compare
That's all the classes done so feel free to review the changes. |
Perfect. Thanks a ton @jsayol! With how large the |
@jsayol If you can please point this PR to https://github.com/firebase/firebase-js-sdk/tree/ts-database/add-new-impl (which will get incrementally merged in #62) then we can get this tested and merged. |
Sure. Should I tag it as [Part 3/3]? |
Yeah, Github didn't like it when I changed the base branch. I might have to rebase, one sec. Edit: done. |
I actually have another part 3 of my own, this will be a piece of part 2 😄 |
Ah! Sorry, jumped the gun there :P |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First look at this is really good. I have been left some comments on the Error/Closure comment style that if you could address would be awesome!
Thank you much for the typescript refactoring! It looks nice so far.
src/database/api/DataSnapshot.ts
Outdated
* @private | ||
* @const | ||
* @type {!fb.core.snap.Node} | ||
* @param {!fb.core.snap.Node} node_ A SnapshotNode to wrap. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we refactor the fb.*.*.* comments? These all have clear analogs in the classes that we reference.
src/database/api/onDisconnect.ts
Outdated
* @return {!firebase.Promise} | ||
*/ | ||
cancel(opt_onComplete) { | ||
validateArgCount('firebase.database.onDisconnect().cancel', 0, 1, arguments.length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change these validate identifiers to
validateArgCount('OnDisconnect.cancel', 0, 1, arguments.length);
I feel like with this being a class we should validate in the same way
Same principle for all of these below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. This originally said Firebase.onDisconnect().cancel
so I changed the Firebase
part to firebase.database
. I've done the same in some other classes too, so just to be clear: in general should I remove the Firebase
/firebase.database
prefix and simply use the ClassName.methodName
format?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, with these classes exposed, directly referencing the classes should be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've addressed both comments, plus a few other things I've found along the way.
I pushed these changes on a separate commit to make them easier to review, let me know if you want me to squash them before merging.
// no-op since we just always call getToken. | ||
} | ||
|
||
/** @inheritDoc */ | ||
onDisconnectPut(pathString, data, opt_onComplete) { } | ||
onDisconnectPut(pathString: string, data: any, onComplete?: (a: string, b: string) => any) { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like converting ServerActions
to an abstract base class with default implementations for these methods would probably remove the need for the empty methods. I don't think it should block this PR but something to do in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that's a good point. I'll create a new PR against ts-database/add-new-impl
with that change, thanks!
I've tested this and things are looking fantastic. I'm in the process of fixing node support and then importing tests so hopefully we can get all of these changes into master soon! |
* refactor(database): classes for typescript database implementation * refactor(database): requested changes & other improvements
* refactor(database): classes for typescript database implementation * refactor(database): requested changes & other improvements
…#62) * refactor(database): add typescript implementation * refactor(database): update build process to include database.ts All integration tests pass at this point * refactor(*): refactor environment builds to be based on separate .ts files * WIP: patch database code in nodeJS * refactor(database): classes for typescript database implementation (#55) * refactor(database): classes for typescript database implementation * refactor(database): requested changes & other improvements * fix(database): Add missing "typeof" (#74) https://github.com/firebase/firebase-js-sdk/blob/fd0728138d88c454f8e38a78f35d831d6365070c/src/database/js-client/core/Repo.js#L86 * WIP: fixes from @schmidt-sebastian's review * WIP: fix: TS Build error * fix(database): fix issue with missing repo method * WIP: review adjustments #1 * WIP: review comments #2
…irebase#55) * refactor(database): classes for typescript database implementation * refactor(database): requested changes & other improvements
* refactor(database): add typescript implementation * refactor(database): update build process to include database.ts All integration tests pass at this point * refactor(*): refactor environment builds to be based on separate .ts files * WIP: patch database code in nodeJS * refactor(database): classes for typescript database implementation (#55) * refactor(database): classes for typescript database implementation * refactor(database): requested changes & other improvements * WIP: add the /tests/config dir to the .gitignore * WIP: add test harness * WIP: add query tests There are some tests that have weird timing issues, and because of the polling nature of the original implementation, we never caught the issue. These should be resolved when able * WIP: add database.test.ts * WIP: add node.test.ts * WIP: add sortedmap.test.ts * WIP: add datasnapshot.test.ts * WIP: add sparsesnapshottree.test.ts * refactor(database): refactor query.test.ts to better preserve original test meaning * WIP: add crawler_support.test.ts * WIP: refactor EventAccumulator.ts for data.test.ts * WIP: fix issue with query.test.ts * WIP: add connection.test.ts * WIP: add info.test.ts * WIP: add order_by.test.ts I only migrated some of these tests as there was a dependency on the server for several tests * WIP: fix several code signature problems, add test files * WIP: add transaction.test.ts * WIP: working on the broken npm test command * WIP: working on fixes * WIP: remove logging * WIP: fix node tests * fix(*): fixing test files and CI integration * WIP: tEMP: Allow branch builds * WIP: escape string * refactor(CI): use ChromeHeadless launcher * WIP: fixes from review. * WIP: skip flakey test * WIP: remove unneeded debugger statement * WIP: fixing nits
* refactor(database): remove old database implementation [Part 1/3] (#61) * refactor(database): remove old database implementation This is part #1 of 4 PR's to migrate database * refactor(database): remove database build processes * refactor(database): Add typescript database implementation [Part 2/3] (#62) * refactor(database): add typescript implementation * refactor(database): update build process to include database.ts All integration tests pass at this point * refactor(*): refactor environment builds to be based on separate .ts files * WIP: patch database code in nodeJS * refactor(database): classes for typescript database implementation (#55) * refactor(database): classes for typescript database implementation * refactor(database): requested changes & other improvements * fix(database): Add missing "typeof" (#74) https://github.com/firebase/firebase-js-sdk/blob/fd0728138d88c454f8e38a78f35d831d6365070c/src/database/js-client/core/Repo.js#L86 * WIP: fixes from @schmidt-sebastian's review * WIP: fix: TS Build error * fix(database): fix issue with missing repo method * WIP: review adjustments #1 * WIP: review comments #2 * WIP: refactor(database): Add migrated test harness [Part 3/3] (#71) * refactor(database): add typescript implementation * refactor(database): update build process to include database.ts All integration tests pass at this point * refactor(*): refactor environment builds to be based on separate .ts files * WIP: patch database code in nodeJS * refactor(database): classes for typescript database implementation (#55) * refactor(database): classes for typescript database implementation * refactor(database): requested changes & other improvements * WIP: add the /tests/config dir to the .gitignore * WIP: add test harness * WIP: add query tests There are some tests that have weird timing issues, and because of the polling nature of the original implementation, we never caught the issue. These should be resolved when able * WIP: add database.test.ts * WIP: add node.test.ts * WIP: add sortedmap.test.ts * WIP: add datasnapshot.test.ts * WIP: add sparsesnapshottree.test.ts * refactor(database): refactor query.test.ts to better preserve original test meaning * WIP: add crawler_support.test.ts * WIP: refactor EventAccumulator.ts for data.test.ts * WIP: fix issue with query.test.ts * WIP: add connection.test.ts * WIP: add info.test.ts * WIP: add order_by.test.ts I only migrated some of these tests as there was a dependency on the server for several tests * WIP: fix several code signature problems, add test files * WIP: add transaction.test.ts * WIP: working on the broken npm test command * WIP: working on fixes * WIP: remove logging * WIP: fix node tests * fix(*): fixing test files and CI integration * WIP: tEMP: Allow branch builds * WIP: escape string * refactor(CI): use ChromeHeadless launcher * WIP: fixes from review. * WIP: skip flakey test * WIP: remove unneeded debugger statement * WIP: fixing nits * Prevent using uninitialized array in EventEmitter (#85) * perf(*): fixing build size output issues * chore(*): remove unneeded build deps
Related to PRs #61 & #62
cc @jshcrowthe