javascript engine: GeoFire not a constructor

I’m using for my app to work with firebase. Works smooth, but now I want to use geofire.

Error message:
[Viewport]: Error: TypeError: GeoFire is not a constructor

What I did:
Include geofire.js in the unoproj file

and added the following code to js file.

var Observable = require('FuseJS/Observable');

if (typeof firebase === "undefined") {
  firebase = require('fuse-firebase');
  // Initialize Firebase
  var config = require('firebase-config');
  // firebase.database.enableLogging(true);

GeoFire = require('geofire');

function addLocation(){
	var needLat = lat.value;
	var needLong = long.value;
	var needMsg = msg.value;

	var needId = firebase.database().ref().child('needs').push().key;

		text: needMsg

	var needslocRef = firebase.database().ref('needs_loc');
	var geoFire = new GeoFire(needslocRef);
	geoFire.setLocation(needId, new GeoLocation(lattitude, longitude));


Where do I go wrong?

I have not tried using that myself. But I would attach the debugger, and see where it stops.

Fortunately release 1.0.1 is out so I can debug again :wink: Missed that one. Wil do it now.

All works smooth till like 25 comes up.

It just stops right there. Doesn’t go into the geofire.js file (or anywhere else for that matter).


[Viewport]: Error: TypeError: GeoFire is not a constructor: Name: TypeError: GeoFire is not a constructor
Error message: Uncaught TypeError: GeoFire is not a constructor
File name: Pages/NeedsPage.js
Line number: 25
Source line: 	var geoFire = new GeoFire(needslocRef);
JS stack trace: TypeError: GeoFire is not a constructor
    at addLocation (Pages/NeedsPage.js:25:16)
 in Fuse.Reactive.FunctionMirror<Pages/NeedsPage.js:25>

Update: Apparently geofire.js only exports when running on Node.

// Export GeoFire if this is being run in node
if (typeof module !== "undefined" && typeof process !== "undefined") {
  module.exports = GeoFire;

For now I have commented the if statement out, so it gets exported no matter what.

Is there a way to do this in a separate js-file not to meddle with the original geofire.js file?

Hi WilfredR,

just an idea, but couldn’t you do something like this?

GeoFire = require('geofire');
GeoFire.process = "something";
// ...
var geoFire = new GeoFire(needslocRef);

The “something” obviously needs to be something that the process variable is expected to be, and I’m sure it’s not a string. What that is you will need to find out yourself.

Thanks Uldis, for helping out a noob, again :wink:

I’ll have a go at it.