Skip to content
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

Fixes LiveQuery behavior on multiple subscriptions #758

Merged
merged 5 commits into from
Mar 22, 2019
Merged

Fixes LiveQuery behavior on multiple subscriptions #758

merged 5 commits into from
Mar 22, 2019

Conversation

Amphaal
Copy link
Contributor

@Amphaal Amphaal commented Mar 22, 2019

Fixes #278

@dplewis
Copy link
Member

dplewis commented Mar 22, 2019

Thank you for the PR.

Test cases are needed. Check out the Contributors Guide

@Amphaal
Copy link
Contributor Author

Amphaal commented Mar 22, 2019

As I peeked into the existing tests for LiveQuery, I'm a bit concerned that my PR is still a hack in it's current state.

ParseLiveQuery being a mere proxy class for LiveQueryClient, i feel like it would be more relevant to implement the Promise-based workflow directly in the LiveQueryClient class, resolving promises after the server acknoledges any instructions.

You are right to assume it might also break things for certain users, but I wonder how any developer could have been able to use the LQ functionality with the framework so far, considering how restricted the working usecase is.

Maybe feedback from developers with actual experience with this functionality is required beforehand ? IMO, Promises are mandatory.

@codecov
Copy link

codecov bot commented Mar 22, 2019

Codecov Report

Merging #758 into master will increase coverage by 0.28%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #758      +/-   ##
==========================================
+ Coverage   89.97%   90.25%   +0.28%     
==========================================
  Files          54       54              
  Lines        4676     4640      -36     
  Branches     1076     1077       +1     
==========================================
- Hits         4207     4188      -19     
+ Misses        469      452      -17
Impacted Files Coverage Δ
src/LiveQueryClient.js 86.62% <ø> (-1.24%) ⬇️
src/CoreManager.js 100% <ø> (ø) ⬆️
src/LiveQuerySubscription.js 100% <100%> (ø) ⬆️
src/ParseQuery.js 96.36% <100%> (+0.61%) ⬆️
src/ParseLiveQuery.js 100% <100%> (+20.25%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aceea03...542f128. Read the comment docs.

@dplewis
Copy link
Member

dplewis commented Mar 22, 2019

@Amphaal I added a few tests to this. Can you check them and add anything you think is missing.

src/ParseQuery.js Outdated Show resolved Hide resolved
src/ParseLiveQuery.js Outdated Show resolved Hide resolved
@acinader acinader self-requested a review March 22, 2019 17:26
@dplewis
Copy link
Member

dplewis commented Mar 22, 2019

@Amphaal @acinader I did some clean up;

I changed the LiveQueryController to only handles getting / setting the LiveQueryClient.

subscribe logic moved to query.subscribe

This makes it much easier to understand how LiveQuery works.

Copy link
Contributor

@acinader acinader left a comment

Choose a reason for hiding this comment

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

this looks good to me. some q's and nits that you can safely ignore.

put in my $.02 ignorantly on the sole question you ask...

@@ -393,10 +393,9 @@ module.exports = {

setLiveQueryController(controller: any) {
requireMethods('LiveQueryController', [
Copy link
Contributor

Choose a reason for hiding this comment

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

can you help me understand what this change is please?

Copy link
Member

@dplewis dplewis Mar 22, 2019

Choose a reason for hiding this comment

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

Those function (subscribe, unsubscribe, open, close) already exists in the LiveQueryClient.

In the LiveQueryController those were just wrapper functions. Instead of using wrapper functions call the ones from the LiveQueryClient (Which you can get from the LiveQueryController).

setDefaultLiveQueryClient, getDefaultLiveQueryClient, _clearCachedDefaultClient already existed but weren't documented.

src/LiveQuerySubscription.js Outdated Show resolved Hide resolved
src/LiveQuerySubscription.js Outdated Show resolved Hide resolved
src/ParseLiveQuery.js Outdated Show resolved Hide resolved
@dplewis dplewis requested a review from acinader March 22, 2019 22:16
liveQueryServerURL = protocol + host;
const serverURL = url.parse(CoreManager.get('SERVER_URL'));
const protocol = serverURL.protocol === 'http:' ? 'ws://' : 'wss://';
liveQueryServerURL = protocol + serverURL.host + serverURL.pathname;
Copy link
Contributor

Choose a reason for hiding this comment

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

hot!

Copy link
Contributor

Choose a reason for hiding this comment

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

uh @dplewis...wait a sec...is this on the client? will the url class be available?

I'm so used to all the parse stuff being on the server, I get a little confused on what's where when it comes to the JS SDK...😬

Copy link
Member

Choose a reason for hiding this comment

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

I forgot about that too. I keep forgetting about other environments besides node.

To answer your question I don't think so. I'll revert it in a PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

https://developer.mozilla.org/en-US/docs/Web/API/URL

not sure what compatibility we're looking for.

@dplewis dplewis merged commit 089e208 into parse-community:master Mar 22, 2019
@dplewis
Copy link
Member

dplewis commented Mar 22, 2019

@Amphaal Thanks for opening the PR. Sorry if I kinda took it over. We can look more deeply into the LiveQueryClient to see if there are improvements to be made.

@Amphaal
Copy link
Contributor Author

Amphaal commented Mar 22, 2019

@dplewis You did great, I honestly don't have much time right now to dig back into Parse... This fix is a great addition to future release !
But I was happy to help, even in the smallest way. I hope this will encourage users to go further with LQ :)

dplewis added a commit that referenced this pull request Mar 26, 2019
dplewis added a commit that referenced this pull request Mar 26, 2019
* ⚡️ Release v2.3.0

Closes: #687, #670, #723, #669

* Pin packages
* (Jest) Fix deprecated setupTestFrameworkScriptFile
* (Codecov) Fix coverage folders
* Update Parse.Cloud.define docs
* Add discource badge to Readme

Pending #753

* add user subclass fix

* add typescript to readme

* typo

* add discourse to js sdk

* remove url module #758 (review)

* Update CHANGELOG.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants