Created
March 6, 2019 01:45
-
-
Save edict3d/2ee3f858d42b9d478c1cab6422e9443d to your computer and use it in GitHub Desktop.
Stream Steem Blocks From Steemit Inc.
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
<script src="https://unpkg.com/dsteem@^0.10.0/dist/dsteem.js"></script> | |
<br><button id="on"> On </button><br> | |
<br><button id="pause"> Pause </button><br> | |
<br><button id="resume"> Resume </button><br> | |
<h1>Output:</h1> | |
<p id='output'></p> | |
<script> | |
var client = new dsteem.Client('https://api.steemit.com') | |
//var stream = client.blockchain.getBlockStream() | |
var stream = client.blockchain.getOperationsStream() | |
function filter(operation){ | |
// Filter operations received to look for @drugwars players battling. | |
console.log(operation); | |
let op = operation.op | |
let data = op[1] | |
if(op[0] === 'custom_json' && data.id === 'drugwars'){ | |
document.getElementById("output").innerHTML += data.id + '<br>' | |
+ data.json + '<br><br>' | |
} | |
} | |
function on(){ | |
stream.on('data', (operation) => filter(operation)) | |
} | |
function pause(){ | |
stream.pause() | |
} | |
function resume(){ | |
stream.resume() | |
} | |
document.getElementById("on").onclick = on | |
document.getElementById("pause").onclick = pause | |
document.getElementById("resume").onclick = resume | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment