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

Using with Ionic 3 Angular / Typescript Project #11

Open
clariontools opened this issue Aug 4, 2017 · 6 comments
Open

Using with Ionic 3 Angular / Typescript Project #11

clariontools opened this issue Aug 4, 2017 · 6 comments

Comments

@clariontools
Copy link

I wasn't expecting this plugin would be a simple plugin add for an Ionic 3 Angular / Typescript project. This may not even be on your radar, but it was something that I am currently evaluating. The current couchbaselabs/Couchbase-Lite-PhoneGap-Plugin is a bit weak by itself with Ionic 3. However, nraboy created couchbaselabs/cordova-couchbase which provides a JavaScript / TypeScript wrapper for the official phonegap plugin. I think it would be fairly easy to create a similar JS / TypeScript wrapper for the cordova-plugin-couchbase-lite plugin using what nraboy did as a starting point. My question is if this is a good approach or do you already have something similar that I just couldn't find?

If this is a good way to go please let me know and give me a little guidance on how this would differ or be implemented compared to nraboy's couchbaselabs/cordova-couchbase wrapper?

@clariontools
Copy link
Author

If you want to take a look at the couchbaselabs/cordova-couchbase wrapper, it is here:

https://github.com/couchbaselabs/cordova-couchbase

@jfspencer
Copy link
Owner

@clariontools I wasn't aware of nraboy's Couchbase-Lite-PhonGap-Plugin wrapper. He is wrapping over the standard REST API, so outside of his external API shape the wrapper guts would be completely different for this project. I wrote a simple wrapper for the main project I use this plugin with. I have added a basic version of it to the repo here it depends on a global instance of lodash fyi, but that is easily changed to an import which would be more standard. the cbl.ts is setup to wrap around a single database, so usage would be

const wrapper = new cbl();
wrapper.init('dbName','syncUrl');
wrapper.sync(); //returns promise containing success or failure message
wrapper.getDoc('id'); //returns promise containing doc

@clariontools
Copy link
Author

Thanks I got pretty far with that, but need more time to integrate properly with Ionic 3.

@jfspencer
Copy link
Owner

jfspencer commented Aug 5, 2017 via email

@jfspencer
Copy link
Owner

It occurred to me that to properly support ionic3 the Promise/RxJS/Lodash wrapping should all happen inside the Typescript wrapper (instead of the cordova www api) so the library dependencies could be imported and injected normally instead of relying on global variables. Eventually the typescript wrapper should be merged into ionic-native itself

@clariontools
Copy link
Author

That is a good point and while I really wanted to see how this would perform with Ionic 3, I started to realize that I do not have the time to do a proper integration atm. Since Ionic is quite a popular development framework, I suspect there would be a lot of interest in your approach. Maybe you could get nraboy to write a blog post about (and possibly contribute to) it since he has written many others over the past few years?

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

No branches or pull requests

2 participants