I'm using Firebase's PHP API to update a Reporting/Dashboard AngularJS app as users do things through our application. The problem is sometimes when I do things too fast Angular app doesn't receive the new data from Firebase immediately. Then all of a sudden it receives a ton of new objects all at once instead of getting them one at a time as they happen.
Is firebase throttling the number of requests to their API? Is this a architecture design flaw?
Laravel framework http://laravel.com/
As you can see nothing special happening here.
$fb = new firebase(Config::get('firebase.url'), Config::get('firebase.token'));
$fb->push("/" . Config::get('firebase.reports_feed') . "/" . Auth::user()->account_user_id, array(
'createdAt' => Date::timezone(Date::sql(), "UTC", Auth::user()->account()->timezone),
'message' => Auth::user()->name . " activated a '{$record->card->name}' system.",
'user' => array(
'id' => Auth::user()->id,
'name' => Auth::user()->name,
),
'reload' => false,
'processed' => false,
'record' => to_json($record),
));
The card object is shallow.
Update
I have two computers I'm testing this on.
- A cheap touchscreen acer - Windows7
- An older compaq - ElementaryOS
I noticed the compaq tends to update before the acer does. Maybe this is a RAM issue with javascript vars being to large? I currently have an array of 225 objects in an activity feed.
Update 2
- I did an action in my app
- it posted to firebase
- Forge went green as it added the records
- Nothing happened with my listener.
- I did the action one to three more times and my app would update all of a sudden.
controllers.controller('ReportsCtrl', function($scope, angularFire) { var ref = new Firebase($scope.main.firebaseUrl + "/" + $scope.main.accountUserId); $scope.feedItems = []; angularFire(ref, $scope, "feedItems");
$scope.$watch('feedItems', function(newVal, oldVal) {
_.each($scope.feedItems, function(item) {
if (!item.processed) {
toastr.info(item.message); // alert message that pops up
item.processed = true;
if (item.reload)
$scope.loadGoalStats();
}
});
$scope.feedItemsLength = _.toArray($scope.feedItems).length;
}, true);
});