Closed Rajan closed 7 years ago
I'm looking to build an iOS app using native Swift and later native Android app. The RethinkDB "changefeeds" is the closest thing to Firebase that I've found. Exploring GunDB and still working to get hold of it. =)
Yeah, right now we don't have support for other languages :( After gun reaches reasonable stability, we're hoping to port to other languages/platforms. In the meantime, we're ironing out some compile-step wrinkles...
If you run into any issues, please let us know and we'll do what we can to help!
If you @Rajan are interested in helping port gun (gun is actually pretty small) we could use the help and I'd provide any assistance you need.
Either way, what language would you vote is the first one we should port to?
Apple Swift 2.0 because it's new and easy and will be effective to help build next set of popular iOS apps. Apple is committed to move it's existing base of Objective-C to Swift (2.0).
It would be great to create a react-native version of gun. You would just need to remove DOM dependent libs. I currently use Firebase for my react-native apps, but would love to switch over to GunDB. @amark
@bpeters I'm in the middle of writing an article on how to do a bare bones minimal port of GUN to your language of choice, for at least communicating to other GUN peers.
Maybe I'm assuming react-native isn't JS? GUN already doesn't require any DOM dependent libs - for example, it runs in NodeJS just fine. Does this mean that it is potentially easy to make it compatible with react-native?
@bpeters I'd like to hear about what project you are working on. Could you jump on the http://gitter.im/amark/gun and share?
Hey @amark I am attempting to integrate GUN into a react-native project but hitting bumps as well.
React-native is JS, however, you do have browser dependent libs in the client (./gun.js
) thats provided ( localStorage
, window
, document
, etc) and the server requires NodeJS modules (url
, fs
, etc).
I haven't had a chance to do a full audit and see what the LOE is to get it working within the react-native environment, but definitely doesn't function out of the box.
@allenhartwig I case detect what environment gun is in and then use that environment's defaults. Making tweaks to this should be easy...
However, I need to know what environment React-Native is in, and what is available. I don't have any experience with React-Native so getting yours (or others) help would be great.
I've created PR #181 to make Gun work within React-Native. The issue was with how Babel assigns this
scope within modules during transpile.
@bpeters you should be able to use like so:
import Gun from 'gun/gun';
var gun = Gun('ws://my_gun_server:port');
var chat = gun.get('chat/global');
var msg = {
date: Gun.time.is(),
text: 'Test Message',
from: 'Test user'
};
var path = msg.date + '_' + Gun.text.random(4);
chat.path(path).put(msg);
chat.map().val(function(msg, field){
console.log(msg);
console.log(field);
});
Nice! Following up with the PR and your email soon.
Some additional work is needed to have localStorage
polyfilled with AsyncStorage
. That will be coming in a followup PR.
I'm wondering what is the status of this ticket, and if any work has been done to enable saving data to AsyncStorage.
I tried this quick snippet in a ReactNative app;
var gun = Gun();
var people = gun.get('people');
var id = Math.floor((Math.random() * 100) + 1);
var name = `person/${id}`;
var person = gun.get(name).put({'name': name});
people.set(person);
people.val(function (data) {
console.log('People:', data);
})
I was expecting people set to persist and increase by one after reloading the app. However, even though the code seem to be working, it always prints the only object saved in current session.
Is this how Gun should be used? Is that the expected result? Also, how come data is saved if AsyncStorage is not supported yet, could it be a file? Cheers!
P.S I'm using gundb version 0.3.994.
@remon-georgy you are correct, that is how it should work, but nobody has written a AsyncStorage
adapter yet :( sad day.
A couple of options:
(complicated?) I think @PsychoLlama said that if you use the gun-level adapter you can plug-in a AsyncStorage for ReactNative (or maybe the default localStorage adapter for level works with ReactNative)? <--- lots of words.
(simple?) The module system in 0.5
(not finished yet, but pretty close - it has all the performance improvements) is pretty easy. It should only take 10 lines of code or so for you to write an AsyncStorage adapter. Would you be up for that? I can help you.
Hey @remon-georgy! So, using gun-level
with asyncstorage-down
should work, but I'm running into a couple issues doing a proof-of-concept (one of which seems rather ominous).
In the end, the code to integrate with AsyncStorage should look something like this...
import Gun from 'gun'
import 'gun-level';
import levelup from 'levelup';
import storage from 'asyncstorage-down';
const db = Gun({
// Save data through levelup.
level: levelup('whatever/name/you/like', {
valueEncoding: 'json',
db: storage,
}),
// Disable default `data.json` storage.
file: false,
});
I've created an issue for one of the gun-level bugs here.
Thanks @amark and @PsychoLlama for the amazing briefing! I'm clear on GundDB's status now.
Level-up route sounds promising, and it opens the door for more integrations. However I still can't wrap my head around that leveldb/up/down ecosystem. Also, it would be great if GunDB has a first class AsyncStorage adapter. I think eventually it will be the most popular adapter.
I think building on top of 0.5 branch is the winning approach, given how simple it should be. Although I don't have much experience with javascript in general, I'm willing to poke around 0.5 branch and see how it goes. @amark do you think looking at existing adapters in /lib is a good start?
@remon-georgy basically, if you can get back to me something that works wth AsyncStorage that looks like this:
Gun.on('put', function(at){
for(var soul in at.put){
localStorage[soul] = JSON.stringify(at.put[soul]);
}
at.cb(null, {ok: "saved"}); // call the ACK callback.
});
Gun.on('get', function(at){
at.cb(null, JSON.parse(localStorage[at.get.soul])); // call the reply callback.
});
Warning: Note! The above code is not a working example, it is more like pseudo-code. But if you are able to make the couple adjustments from its skeleton-structure to work with AsyncStorage, then that will be enough for us to get you the real version.
Welcome to JS! It can be confusing ;) thanks for being willing to give it a stab. If you get confused though, don't... struggle or get depressed. Ask for help. :)
Any examples of working with polymer?
@moses5407 actually a ton! @Stefdv has a huge library for it: https://github.com/Stefdv/gun-ui-lcd , as well as many other examples and demos.
Wow! Thanks! I like firebase but really want an independent database solution.... ya know..the Parse thing ..
Open Source all the way!
Aloha, Mark
I'd like to contact you privately regarding a potential project using Gundb. I don't want it in general conversation just yet. Is there a best comm channel?
Thanks
On Fri, Feb 3, 2017 at 5:46 PM, Mark Nadal notifications@github.com wrote:
@moses5407 https://github.com/moses5407 actually a ton! @Stefdv https://github.com/Stefdv has a huge library for it: https://github.com/Stefdv/gun-ui-lcd , as well as many other examples and demos.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/amark/gun/issues/139#issuecomment-277416113, or mute the thread https://github.com/notifications/unsubscribe-auth/AFNoQysFZlrF3smY1zu0zRIDW9AnXc4Iks5rY_SDgaJpZM4G78Al .
Absolutely, send an email to mark@gunDB.io !
Re: original issue. People have gotten it to work with ionic, react native, and others, so we're gonna close this thread. Cheers!
we can use it with webview
Hello,
I'm excited to discover gundb as i was looking for firebase alternatives. The problem I see is: Gun seems to be limited to web browsers as it's javascript dependent. I don't know how to leverage for building mobile-apps for iOS/Android?
Thanks, Rajan