Skip to content

Clean up IndexedDb initialization #2163

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

Merged
merged 2 commits into from
Sep 9, 2019
Merged

Conversation

schmidt-sebastian
Copy link
Contributor

My next PR is going to add one more argument to IndexedDbPersistence, so I thought it was a good idea to clean up the initialization a tiny bit.

Copy link
Contributor

@mikelehen mikelehen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with minor nits.

As an aside, I wouldn't complain if you added a bit more detail in your PR descriptions to make it easier for me to figure out what I'm looking at. 😄 E.g.

  • Combined IndexedDbPersistence.createMultiClientIndexedDbPersistence() and IndexedDbPersistence.createIndexedDbPersistence() factory methods into a single method by relying on the fact that MemorySharedClientState has a suitable "no-op" implementation of SequenceNumberSyncer that we can use when multitab is disabled.
  • Converted new factory method to take an options object for reasons.

Not a huge deal, but with refactors there are often a lot of lines changed (+80,-130 in this case) for a small conceptual change or two. So it's helpful if you can just highlight the conceptual changes and save me the effort of reverse-engineering what changed before I can then re-review and decide if I agree with the changes and whether they were implemented correctly.

options.lruParams,
options.queue,
options.serializer,
options.sequenceNumberSyncer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems slightly odd and arbitrary for createIndexedDbPersistence() to take an options object but then we flatten that into separate arguments when calling the IndexedDbPersistence constructor.

I don't care very strongly, but it seems like it'd be cleaner to either convert both to options objects or just use plain arguments for both.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with "odd", but I wanted to make this long list of arguments more readable, so I opted for the options object for the external API. If I use an options object in the constructor though, then I would have to declare all fields explicitly again. This is my compromise for the best (and worst) of all worlds.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right! That's a pretty good reason.

private readonly queue: AsyncQueue,
serializer: JsonProtoSerializer,
lruParams: LruParams,
private readonly multiClientParams?: MultiClientParams
private readonly sequenceNumberSyncer?: SequenceNumberSyncer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like with this change, you are always passing a sequenceNumberSyncer, so this may not need to be optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For IndexedDb it doesn't have to be optional anymore.

@@ -278,25 +261,19 @@ export class IndexedDbPersistence implements Persistence {
// is still experimental. When multi-client is switched to always on, `multiClientParams` will
// no longer be optional.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stale comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

Copy link
Contributor Author

@schmidt-sebastian schmidt-sebastian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review! I will try to be a bit more expressive when it comes to explaining my intentions. Promise :)

options.lruParams,
options.queue,
options.serializer,
options.sequenceNumberSyncer
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with "odd", but I wanted to make this long list of arguments more readable, so I opted for the options object for the external API. If I use an options object in the constructor though, then I would have to declare all fields explicitly again. This is my compromise for the best (and worst) of all worlds.

@@ -278,25 +261,19 @@ export class IndexedDbPersistence implements Persistence {
// is still experimental. When multi-client is switched to always on, `multiClientParams` will
// no longer be optional.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

private readonly queue: AsyncQueue,
serializer: JsonProtoSerializer,
lruParams: LruParams,
private readonly multiClientParams?: MultiClientParams
private readonly sequenceNumberSyncer?: SequenceNumberSyncer
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For IndexedDb it doesn't have to be optional anymore.

@schmidt-sebastian schmidt-sebastian merged commit 0462045 into master Sep 9, 2019
@schmidt-sebastian schmidt-sebastian deleted the mrschmidt/builder branch September 9, 2019 19:09
@firebase firebase locked and limited conversation to collaborators Oct 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants