Rudiksz / couchbase_lite_dart

Dart implementation of the Couchbase Lite, an embedded, NoSQL JSON Document Style database.
BSD 3-Clause "New" or "Revised" License
24 stars 3 forks source link

Great start! #1

Closed bawelter closed 3 years ago

bawelter commented 4 years ago

Hey just wanted to say awesome work on the progress. This is exactly what was needed. I was hoping to do this when I had a chance but was consumed by other work related tasks. If I can help let me know.

bawelter commented 4 years ago

Also if this is a pure dart package you should be able to remove the android folder I believe. Just one less thing to mess with.

Rudiksz commented 4 years ago

Thank you. Help is always appreciated.

There's still ways to go before it is production ready. Where do I even start?

The API is 99% complete, what still needs to be done is: 1) making the database change listeners thread safe. I just need time to refactor them to how replicator change listeners are handled. The replicator runs on a separate thread by default so I had to make the listeners thread safe and Dart isolate safe from the start.

2) refactor replicator proxy configuration to use basic C type. I found that with ffi, passing Structs created in Dart, from Dart to C, can lead to random crashes. "Flattening" everything to basic C types and creating the replicator config object on C side eliminates all the crashes. That's why the replicator constructed the way it is now.

3) implementing replicator conflict handler. This is similar to push/pull fiters so again only issue is to set aside time for the implementation and specially for testing.

4) Replicated document listeners seemed to have some bug in the C library, but they are low on my priority list so I canned them for now.

These are good first issues to start with if you'd like to get your hands dirty, and I believe they would complete the API.

Two areas that need a lot of improvement to make the package ready for prime time and impact the internals are:

It's not a pure Dart library per se, it relies on the platform specific libraries.

I have the Windows and Android libraries built, with the windows dll bundled together with the package. For Android I would probably have to publish them somewhere and then have Gradle bundle them in the app so the package can find it. I wasted 3 days unsuccessfully before I gave up (hence the useless Android folder :)). Documentation on how to do is pretty much inexistent or irrelevant to my case.

I did test the package on Android by manually adding the .so files to the Flutter app itself and it was promising.

For iOS, macOS I have absolutely no clue, but of course would be nice to have support eventually.

Here is my fork of the couchbase-lite-C library with some custom code required for Dart, if you are interested in building for macOS or iOS https://github.com/Rudiksz/couchbase-lite-C

Currently I'm working on porting my Flutter app to Windows using this plugin, and fixing things as I go but there was not much to fix yet. I have had some crashes but I belive it's either due to some thread/memory issues between Dart and C code, or even just flutter's hotreload creating weird race conditions. It is quite stable already.

PS: probably I will create separate github issues for the things here (unless I fix them myself this weekend), but I guess this is a good summary of where I am now