Last active
August 29, 2015 14:26
-
-
Save xmlking/ed6ec1f794484aa28fae to your computer and use it in GitHub Desktop.
Demonstrate streaming JSON data parsing with OboeJS lib. Client consuming streaming REST endpoint implemented using NodeJS/RxJava/Ratpack etc and -chunked transfer- encoding
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
<html> | |
<head> | |
<title>OboeJS demo</title> | |
<script src="https://rawgit.com/jimhigson/oboe.js/v2.1.2/dist/oboe-browser.min.js"></script> | |
</head> | |
<body> | |
<div ></div> | |
<ul id="content"> | |
<li>AUD_CAD:</li> | |
</ul> | |
<script> | |
var ele = document.getElementById("content"); | |
oboe('http://stream-sandbox.oanda.com/v1/prices?accountId=12345&instruments=AUD_CAD%2CAUD_CHF') | |
.node('tick', function(things) { | |
var span = document.createElement('li'); | |
span.innerText = "instrument: "+things.instrument+", time: "+things.time+", bid: "+things.bid+", ask: "+things.ask; | |
ele.appendChild(span); | |
console.log( 'Got tick', things); | |
}) | |
.node('heartbeat', function(things) { | |
console.log( 'Got heartbeat', things); | |
}) | |
.fail(function() { | |
console.log( 'Oops'); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment