Skip to content

Instantly share code, notes, and snippets.

@Sebmaster
Sebmaster / client.js
Last active December 16, 2015 15:39
Method to implement data-synchronization in angular.js via racer.js
var module = angular.module('racer.js', [], function ($provide) {
var setImmediate = window && window.setImmediate ? window.setImmediate : function (fn) {
setTimeout(fn, 0);
};
var racer = require('racer');
$provide.factory('racer', ['$http', '$q', '$rootScope', function ($http, $q, $rootScope) {
$http.get('/model').success(function (data) {
racer.init(data);
});