Git Product home page Git Product logo

Comments (5)

hansemannn avatar hansemannn commented on May 26, 2024

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.

from titanium-firebase.

AppWerft avatar AppWerft commented on May 26, 2024

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){

})

from titanium-firebase.

hansemannn avatar hansemannn commented on May 26, 2024

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:

  • Other API naming to be more consistent
  • Use present-sense for events (change vs changed) to match common Node / Titanium event naming convention
  • Add cancel event
  • Add "getValue" method that makes it possible to pass a type that on the native side can then be mapped to "String.class" for example

If you are able to do Android, I'll provide iOS.

from titanium-firebase.

AppWerft avatar AppWerft commented on May 26, 2024

very good ideas. I used createDatabaseReference because of native name. But getReference is fine. I think you don't think about a proxy?

from titanium-firebase.

hansemannn avatar hansemannn commented on May 26, 2024

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.

from titanium-firebase.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.