Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 
avatar of Mattias

Mattias

Mattias has asked 2 questions and find answers to 5 problems.

Stats

109
EtPoint
27
Vote count
2
questions
5
answers

About

var webSocket = new WebSocket('ws://127.0.0.1:1234'); var requests = {};

webSocket.onmessage = function(unparsedMessage){ console.log("Received message " + unparsedMessage); var message = JSON.parse(message.data); var options = requests[value.requestId] delete requests[value.requestId]; options.success(value); };

Backbone.sync = function(method, model, options){ requestID = GuidGenerator.generateGuid(); var message = JSON.stringify({ messageType options.messageType, requestID: requestID, data:model.attributes }); webSocket.send(message); console.log("Sending message " + message); requestMap[requestID] = options; };

var test= new Test(); test.fetch({ messageType: 'TEST' });

GuidGenerator { var generateGuid = function generateUUID(){ var d = new Date().getTime(); var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = (d + Math.random()*16)%16 | 0; d = Math.floor(d/16); return (c=='x' ? r : (r&0x3|0x8)).toString(16); }); return uuid; }; }

type BlahId= {blahId: number}; type BlahCode= {blahCode: string};

function simpleFunction(data: blahId) { console.log(data.blahId); }

type Blah = { blahId: BlahId, blahCode: BlahCode }

function advancedFunction(blah: Blah) { console.log(blah.blahId); }

https://gist.github.com/michaelcox/3800736 http://chaijs.com/plugins/chai-backbone