Last active
August 29, 2015 14:28
-
-
Save katopz/f3970bf1d5b342a8d24c to your computer and use it in GitHub Desktop.
Firebase via Meteor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// You have 3 choices | |
// 1st : npm way, you can use any npm after this (yeah!) | |
// Refer to : http://stackoverflow.com/questions/10165978/how-do-we-or-can-we-use-node-modules-via-npm-with-meteor | |
// $ meteor add meteorhacks:npm | |
// 2nd : mrt way | |
// $ meteor add mrt:firebase | |
// 3rd : diy way | |
// refer to : https://gist.github.com/kenyee/6307258 | |
// now add firebase_bridge.js to your_foo_app/server/firebase_bridge.js | |
// You will get ReferenceError: EJSON is not defined, you have 2 options here. | |
// 1st : use global package which can add via terminal in your app directory | |
// $ meteor add ejson | |
// 2nd : use private variable in your js | |
// var EJSON = Package.ejson.EJSON; | |
// if you use npm way, you will need this... | |
// var Firebase = Meteor.npmRequire("firebase"); | |
var firebase = new Firebase('https://radiant-inferno-foo.firebaseio.com/'); | |
firebase.on('child_added', willLog); | |
firebase.on('child_changed', willLog); | |
firebase.on('child_removed', willLog); | |
function willLog(snapshot) { | |
console.log(snapshot.key() + " : " + EJSON.stringify(snapshot.val())); | |
} | |
// when build with 'meteor' you will get | |
/* | |
[[[[[ ~/foo ]]]]] | |
=> Started proxy. | |
=> Started MongoDB. | |
Loading plugin `initializing-npm-supp... - | |
-> creating `packages.json` for the first time. | |
-> add your npm modules to `packages.json` | |
=> Creating container package for npm modules | |
-> npm support has been initialized. | |
-> please start your app again. | |
*/ | |
// Now edit packages.json | |
/* | |
{ | |
"firebase":"2.2.9" | |
} | |
*/ | |
// and run meteor | |
// $ meteor | |
/* | |
[[[[[ ~/-foo ]]]]] | |
=> Started proxy. | |
=> Started MongoDB. | |
npm-container: updating npm dependencies -- firebase... | |
Changes to your project's package version selections: | |
npm-container added, version 1.1.0 | |
=> Started your app. | |
=> App running at: http://localhost:3000/ | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment