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

LocalDatastore can update from server #734

Merged
merged 6 commits into from
Mar 15, 2019

Conversation

dplewis
Copy link
Member

@dplewis dplewis commented Feb 13, 2019

Allows for updating LocalDatastore with server data

Any advice would be helpful

@codecov
Copy link

codecov bot commented Feb 13, 2019

Codecov Report

Merging #734 into master will increase coverage by 0.08%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #734      +/-   ##
==========================================
+ Coverage   88.74%   88.83%   +0.08%     
==========================================
  Files          53       53              
  Lines        4584     4620      +36     
  Branches     1064     1069       +5     
==========================================
+ Hits         4068     4104      +36     
  Misses        516      516
Impacted Files Coverage Δ
src/LocalDatastore.js 98.98% <100%> (+0.22%) ⬆️

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 41010b9...8f66e4a. Read the comment docs.

@flovilmart
Copy link
Contributor

Did you check how the other SDKs implémented those features? I’m not sure the server is properly equipped to ‘sync’ data when it’s been off sync?

Sent with GitHawk

@dplewis
Copy link
Member Author

dplewis commented Feb 13, 2019

Did you check how the other SDKs implémented those features?

If by other SDK's you mean iOS and android LDS, I don't believe they have this kind of feature. They do have saveEventually for syncing

I’m not sure the server is properly equipped to ‘sync’ data when it’s been off sync?

I'm not looking for a true sync feature with this PR. Just when network reconnect perform a query.

We could add an optional scheduler that will sync it periodically or with user could call this function whenever they wanted to sync data

@flovilmart
Copy link
Contributor

That’s not what I meant, when you will get network connection again, you will attempt to save object, and may override previous operations. But I guess you already knew that.

Sent with GitHawk

@flovilmart
Copy link
Contributor

The REstController also is not the best spot to get this feature in, as it’s responsibility is solely to connect to the API. It has nothing to do with the LDS.

Sent with GitHawk

@dplewis
Copy link
Member Author

dplewis commented Feb 13, 2019

The REstController also is not the best spot to get this feature in

That makes sense. When do you believe the best implementation is? I would like to the SDK to handle it. Any advice would be appreciated

@acinader Thoughts

@dplewis dplewis changed the title LocalDatastore sync with network on reconnect LocalDatastore sync with network Feb 13, 2019
@dplewis dplewis changed the title LocalDatastore sync with network LocalDatastore can update from server Feb 13, 2019
@GoMino GoMino mentioned this pull request Feb 13, 2019
@dplewis
Copy link
Member Author

dplewis commented Feb 14, 2019

@flovilmart How does this look?

@flovilmart
Copy link
Contributor

@dplewis ask @acinader :)

Sent with GitHawk

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.

trying to wrap my head around this....

src/LocalDatastore.js Outdated Show resolved Hide resolved
src/LocalDatastore.js Show resolved Hide resolved
src/Parse.js Outdated Show resolved Hide resolved
src/Parse.js Outdated Show resolved Hide resolved
@dplewis dplewis requested a review from acinader March 15, 2019 16:10
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.

lgtm. one question about the logger.

this.isSyncing = false;
} catch(error) {
console.log('Error syncing LocalDatastore'); // eslint-disable-line
console.log(error); // eslint-disable-line
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason not to use parse's logger so this stuff shows up in aggregated logs?

see middlewares, MogoTransform, PromiseRouter, etc. for examples

Copy link
Member Author

Choose a reason for hiding this comment

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

something like

const Logger = require('parse-server/lib/logger');

Logger.logger.error(`Error syncing LocalDatastore: ${error}`);
console.log('Error syncing LocalDatastore', error);

Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to not follow the exact pattern we have already?

i.e.

https://github.com/parse-community/parse-server/blob/master/src/PromiseRouter.js#L10

import log from './logger';
...
log.error('message', object);
...

and remove the console.log and the eslint exception comment?

Copy link
Member Author

@dplewis dplewis Mar 15, 2019

Choose a reason for hiding this comment

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

Thats the parse-server repo, there isn't a logger in this repo that I know of.

Copy link
Contributor

Choose a reason for hiding this comment

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

ha. riiiight. yeah, lgtm. ;) . I don't use the client js sdk is the only lame excuse i have for that one.

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