Closed AppWerft closed 6 years ago
The mainly used feature is Analytics, but if you want to implement Realtime Databases as well, please propose an API, so the community can discuss it.
This is my proposal:
Following https://firebase.google.com/docs/database/android/start/
var ref = require("firebase.database").createDatabaseReference('message'); // make an instance
ref.setValue('Hello TitaniumWorld');
ref.addEventlistener('changed',function(e){
})
Here is mine:
var FirebaseDatabase = require('firebase.database');
var reference = FirebaseDatabase.getReference('message');
reference.addEventListener('change', function(e) {
var value = e.snapshot.getValue({
type: 'String'
});
Ti.API.info(value);
});
reference.addEventListener('cancel', function(e) {
Ti.API.info(e.error);
});
reference.setValue('Titanium rocks!');
Basically your version, but with some changes:
If you are able to do Android, I'll provide iOS.
very good ideas. I used createDatabaseReference
because of native name. But getReference
is fine. I think you don't think about a proxy?
nope, proxies are not necessary and even a bad idea, because they collide with the concepts of shared objects / singletons. We do not and should not need to retain any reference as we can receive a fresh copy every time we call getReference
.
P.S.: I am implementing the iOS part now, will be available later today. Watch out for https://github.com/hansemannn/titanium-firebase-database
EDIT: Of course we need proxies to me more flexible on the APIs and not wrap everything into a dictionary. But we should be cautious storing strong references it it that may cause persistence- and integrity-issues.
Whats about the mainly used feature?