rxdb icon indicating copy to clipboard operation
rxdb copied to clipboard

Fix react-native example based expo

Open msotnikov opened this issue 2 years ago • 11 comments

This PR contains

Updated example for react-native based on Expo. Main changes

  • rxdb version fixed to 12 to prevent errors after main repo upgrade.
  • react-native downgraded 0.64.3 according expo recomendations

Todos

The sync doesn't work. I have no idea how to do it without server. I can fix it if anybody point what to do

msotnikov avatar Jul 22 '22 04:07 msotnikov

A main reason for having these example projects, is to know when a change on the rxdb code breaks compatibility. So I do not want to install rxdb from npm but it should use the build rxdb bundle. Also having a fixed version there would mean that someone has to come and update it on each rxdb release.

pubkey avatar Jul 22 '22 16:07 pubkey

Ok, changed back. Added comment in readme.md.

msotnikov avatar Jul 22 '22 21:07 msotnikov

Can you update this line https://github.com/pubkey/rxdb/blob/master/.github/workflows/main.yml#L450 So that it does use the node version from the node-version-file: '.nvmrc' like in the other ci tasks.

pubkey avatar Jul 22 '22 23:07 pubkey

expo-cli doesn't support node 18. https://github.com/expo/expo-cli/issues/4478

msotnikov avatar Jul 23 '22 04:07 msotnikov

I see. I am not sure if we should merge this then. Because we increase the expo version but decrease the react-native version, which does not lead to any benefit.

pubkey avatar Jul 23 '22 14:07 pubkey

I see. I am not sure if we should merge this then. Because we increase the expo version but decrease the react-native version, which does not lead to any benefit.

But current code don't work any case :-)

Now updated only expo-cli. I leave old expo package and it have recommendations https://docs.expo.dev/versions/latest/#each-expo-sdk-version-depends-on-a. It was downgraded to prevent notification.

I'll try to update all deps

msotnikov avatar Jul 23 '22 14:07 msotnikov

With jest-expo >= 44 tests passes, but finishes with seg fauilt (yarn and npm same). Now its works.

msotnikov avatar Jul 24 '22 04:07 msotnikov

Replication does not work because you switched from the pouchdb RxStorage to the memory RxStorage. But the replication code uses the CouchDB replication protocol which only works with PouchDB RxStorage.

pubkey avatar Jul 25 '22 11:07 pubkey

Is there a reason why you switched to the memory adapter? Because PouchDB is the only persistent RxStorage for react native, so the whole reason for the react-native example is to explain how to store data in it with the PouchDB RxStorage.

pubkey avatar Jul 26 '22 15:07 pubkey

Is there a reason why you switched to the memory adapter? Because PouchDB is the only persistent RxStorage for react native, so the whole reason for the react-native example is to explain how to store data in it with the PouchDB RxStorage.

The entire PouchDb ecosystem is very outdated. For example, pouchdb-adapter-asyncstorage uses the deprecated async-storage (it was moved to community package). I had patched that package and fix that - the persistance works, but it doesn't fix sync. I tried to find working packages, but only the sqlite package with a bunch of crutches worked.

So, for this PR, we should deside what requirements are needed:

  • persistence?
  • sync throught http?
  • ... ?

msotnikov avatar Jul 26 '22 17:07 msotnikov

Yes both is needed. The reason for making the react native example was to show that RxDB can work with the react-native SQLite storage. We can switch from couchdb-sync to the rxdb replication of course.

I assume this PR is made in context of the premium tasks, is that correct?

pubkey avatar Jul 28 '22 16:07 pubkey

Yes both is needed. The reason for making the react native example was to show that RxDB can work with the react-native SQLite storage. We can switch from couchdb-sync to the rxdb replication of course.

I assume this PR is made in context of the premium tasks, is that correct?

Previous version doesn't use sqlite, it uses asyncstorage.

I have some success with custom version of pouchdb-adapter-react-native-sqlite in my project. But yes, I want to try your version of sqlite connector because, as I mention before, the whole pouchdb ecosystem is outdated.

I'll try to change the adapter to sqlite in this example project.

msotnikov avatar Aug 08 '22 17:08 msotnikov

Recent changes:

  1. Dependencies updated to current versions - [email protected], [email protected], [email protected], [email protected]
  2. Sync has fixed and tested with [email protected] instance (not included). Also, tested with [email protected] - doesn't work.

There is no persistance functionality. Pouchdb need a crunches and Sqlite need a native modules to work. I don't want to deal with it for Expo. My suggestion is - rename this module to react-native-expo and leave as is in this PR. And create a new one with bare react-native.

msotnikov avatar Sep 01 '22 11:09 msotnikov

  • Persistence with pouchdb-adapter-asyncstorage will work after this PR https://github.com/seigel/pouchdb-react-native/pull/154

  • Tests had fixed

msotnikov avatar Sep 01 '22 14:09 msotnikov

Strange error, I restarted the failed CI test.

pubkey avatar Sep 05 '22 17:09 pubkey

I removed the cache settings. In any case, there is no package-lock file. And if I understood you correctly - you want to always have fresh packages.

The buggy jest and CI. I don't know how to fix it. Tests passed locally. Lost my patience. I'll be back later.

msotnikov avatar Sep 05 '22 17:09 msotnikov

So... Now we will test database.

msotnikov avatar Sep 06 '22 06:09 msotnikov

The code looks good to me. What is the state of the sync now? I see it connects to 'http://admin:mysecret1@localhost:5984' but there is nothing started at this port. As far as I remember the pouchdb sync did work before, or was it broken anyway?

pubkey avatar Sep 13 '22 10:09 pubkey

The code looks good to me. What is the state of the sync now? I see it connects to 'http://admin:mysecret1@localhost:5984' but there is nothing started at this port. As far as I remember the pouchdb sync did work before, or was it broken anyway?

There was the similar code before^ const syncURL = 'http://localhost:10102/'; // Replace localhost with a public ip address!

I haven't seen this code works. I haven't seen any server side also.

msotnikov avatar Sep 13 '22 15:09 msotnikov

Ah, you are right, sorry havent seen that there never was a server. So I can merge this now?

pubkey avatar Sep 13 '22 16:09 pubkey

Counting for it :-)

msotnikov avatar Sep 13 '22 16:09 msotnikov

Merged, thank you for your work. You can ping me in discord for the access to the premium plugins.

pubkey avatar Sep 13 '22 16:09 pubkey