realm / realm-js

Realm is a mobile database: an alternative to SQLite & key-value stores
https://realm.io
Apache License 2.0
5.6k stars 557 forks source link

Cordova / PhoneGap / Ionic Support #261

Open timanglade opened 8 years ago

appden commented 8 years ago

I just rebased and pushed my older WIP branch, sk-cordova, which pretty much completes this task. :smile:

appden commented 8 years ago

I mean for iOS. For Android, this is pretty much blocked on #262 being done.

keithdmoore commented 7 years ago

👍 for Ionic support. Hopefully Ionic2!

mlynch commented 7 years ago

This would be awesome and well received in the Ionic community for sure. Curious why this wouldn't Just Work given the recent realm-js release?

philliphartin commented 7 years ago

@mlynch I would assume because for phonegap, an interface between the js library to the native hardware of the device would need to be developed to actually bring the benefit of realms speed. But then again, I have no idea.

alazier commented 7 years ago

The main issue with supporting phonegap/cordova at the moment is the need to support android. React Native runs on JavascriptCore on both iOS and android which is how we support both platforms. This is not the case for cordova/phonegap.

caiobalthazar commented 7 years ago

+1

douglasjunior commented 7 years ago

It's a good option to create a cordova-plugin to use realm-java and realm-cocoa?

As in https://github.com/mapsplugin/cordova-plugin-googlemaps

PierBover commented 7 years ago

The main issue with supporting phonegap/cordova at the moment is the need to support android

@alazier can you expand on that?

alazier commented 7 years ago

@PierBover - the way the Realm binding works is that we hook directly into the JS context for whatever environment we are supporting. React-native uses the same version of JavascriptCore on both ios and android which makes integration pretty straightforward. Cordovoa uses whatever the builtin JS interpreter is on the device it is running on, which makes things much more difficult. It might be possible to make things work by rolling a custom version of Cordova but this isn't something we have looked into. If you just want to support Cordova/iOS then it should be possible to get things working using the current codebase by getting the JSContext from a webview and passing it into the Realm initialization methods, but this is not something that we can currently support or maintain.

PierBover commented 7 years ago

Ok I see the problem.

Probably the best way to go for Cordova/Phonegap is making a native plugin (since you already have native iOS and Android libraries) with a JS wrapper API that mimics the one used in your React Native implementation.

virtualprodigy commented 7 years ago

My team really wants Realm for Cordova/Ionic. Any updates on if/when Cordova support would rollout?

ghost commented 7 years ago

+1

caiobalthazar commented 7 years ago

I believe a plugin approach such as the one described by @PierBover would be the easiest way to do it.

kitfactory commented 7 years ago

+1

faraazc commented 7 years ago

+1 ionic2 support is really wanted in the community. This will open doors for PWA as well.

AresDev commented 7 years ago

+1

gozur commented 7 years ago

+1

ghost commented 7 years ago

+1 IONIC2 support is wanted

krasnokojiy commented 7 years ago

+1

konrin commented 7 years ago

+1

IvanAR commented 7 years ago

+1

llearn commented 7 years ago

+1

gkTim commented 7 years ago

Any news on this?

jruef commented 7 years ago

+1

karapigeon commented 7 years ago

As far as I know, this is not something that we are actively working on right now.

zuhrulumam commented 7 years ago

+1

danmatthews commented 7 years ago

Damn, it's a shame that this isn't something that's actively being worked on - i think it's a big market potentially.

In the meantime, if you're not working on this, can someone close it and update it with some official news?

In the meantime guys - the best alternative is PouchDB with the sqlite adapter.

jruef commented 7 years ago

@danmatthews yeah it's a shame. I develop ionic and react native apps. For react native you can use pouchdb-adapter-react-native-sqlite and pouchdb-react-native :-) and realmjs supports react native.

@danmatthews by the way the first link in your comment is broken

kristiandupont commented 7 years ago

Yeah, sorry, the official news is that @istx25 is right. This is not something we are working on at the moment. I realize that it's a popular request and definitely something we will look into but at the moment, the JS team has plenty of work with the currently supported platforms. I'll keep the issue open as it's neither done nor rejected, just idle :-)

danmatthews commented 7 years ago

No worries! Thanks for getting back to us and letting us know the status.

AsimNet commented 7 years ago

+1

bmunkholm commented 7 years ago

https://github.com/airamrguez/cordova-plugin-realm is making an attempt.

useitsoftware commented 7 years ago

+1 any chance of rethinking on this? angular2/angular4 and ionic 2 are growing platforms with a lot of popularity. You could partner with the ionic team to share the development burden.

malhobayyeb commented 6 years ago

+1

tryadelion commented 6 years ago

@kristiandupont @alazier could you please try to throw this back on the #Maybe deck ? Ionic2/Angular2 & ionic3/Angular4 both lack a solid mautre & stable database system like Realm behind and their platform and numbers of apps is growing fast. showcase.ionicframework.com/apps/newest

nazrdogan commented 6 years ago

+1

dav021 commented 6 years ago

+1

yosuke1985 commented 6 years ago

+1

ozexpert commented 6 years ago

What's the status? I've used React Native with Realm. But want to switch over using Ionic/Cordova with Realm. Blazingly fast database!!

tryadelion commented 6 years ago

What is the status again? it's been almost half a year since @kristiandupont 's statement. React native isn't the only cross platform JS framework, centering yourselves on it forces the rest of us to look elsewhere for worse solutions.

syc-pad commented 6 years ago

+1

tryadelion commented 6 years ago

Feature Request:

Goals

To achieve realm connection between a cordova-based hybrid app and the native library code by creating a cordova Typescript plugin that takes a generically Inputted syntax (RealmJS syntax?, swift syntax?) that redirects to the desired methods in the native code.

Examples of how this works:

https://github.com/arnesson/cordova-plugin-firebase

Expected Results

TS Plugin Usage:

import { RealmDB, RealmObject} from "Realm";
private car : RealmObject = {brand: "honda",subtype:"civic",codename:"grizzlybear",year:"2017",id: 12043};
constructor(realmInstance : RealmDB){
    realmInstance.open().subscribe( () => {
        realmInstance.write(car).subscribe( (res : Boolean) => {
          console.log(res);
        }
    });
}

TS BACKEND:

exports.open = function(success, error) { exec(success, error, "FirebasePlugin", "open"); };

Native IOS:

_let realm = try! Realm()

etc...

native Android: if (action.equals("open")) { return realm.open( etc... } etc,,,,

REASON

Realm.JS isn't made to be used as front end for webview-based hybrid apps, so there must be a way to use it. the easiest is to move the code "behind", and connect to the desired core when platform meets needs.

Possible compatible versions

Android Ios Windows 10 UWP (surface, desktop, windows phone All in One)

bmunkholm commented 6 years ago

We currently don't have the spare capacity to take on more new platforms. There is a significant amount of work involved in creating, maintaining and providing support for each platform. So we would need the community to step up and assist with this effort. I can see that some effort is being put into https://github.com/airamrguez/cordova-plugin-realm.

superandrew commented 6 years ago

+1

tryadelion commented 6 years ago

@bmunkholm hey brian, we understand that the capacity to make a new platform from scratch can be breathtaking. the issue with cordova-plugin-realm is that it relies on premade and predefined scheme files, built over json files. I have no experience on React Native, but i suppose that what it does is detect concrete javascript method calls, and direct them to a native code that takes care of it. correct me if i'm wrong. doing a Cordova wrapper that connected a Realm-JS'subset' of TS/JS calls with the already existant Realm-JS native (as in android/ios, not as in React) calls (and the already existing RealmJS syntax and boilerplate) could take some time to tinker, and a lot to test for a one man project (like any of us could do, or like cordova-plugin-realm is), but would be fast enough for multiple persons that do know how stuff works behind when doing it.

in the extreme end the community would be in charge of doing this kind of feature, we would appreciate a sample android studio module and ios pod (with their usage guides) with the Native side of the RealmJS calls, that we could later wrap it in a cordova module.
something like: //run RealmStore.write( JsonObject object ) to open a write transaction, given a valid RealmJS schema object.syncronous method. returns a boolean if success or not. //run RealmStore.defineSchema(JsonObject object,boolean update) to define a schema. if already exists, it will be ignored unless update is sent. syncronous method. returns a boolean if success or not.

bmunkholm commented 6 years ago

@tryadelion As mentioned it's unfortunately not something that we can devote resources for at the moment. Depending on the help needed though, we would need to get some commitment from the community to this. Perhaps @fealebenpae has input to how best to approach this.

rethinkedu commented 6 years ago

+1

kabus202 commented 6 years ago

+1

RoyGoode commented 6 years ago

+1 for Ionic/Cordova