Skip to content

Instantly share code, notes, and snippets.

@nb1page
Last active May 21, 2020 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nb1page/439165a909a5b6e5149425f9c3f65aa4 to your computer and use it in GitHub Desktop.
Save nb1page/439165a909a5b6e5149425f9c3f65aa4 to your computer and use it in GitHub Desktop.
NB-Dispatch Simple Test
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Extension_test</title>
<script src="https://unpkg.com/@nucleome/nb-dispatch"></script>
</head>
<body>
<div id="connection"></div>
<button id="btn" >Navigate to chr2:10001-50000 </button>
<div id="message"></div>
<script>
(function()
{
var chan = nb.dispatch("update","brush")
chan.connect(function(d){
document.getElementById("connection").innerHTML = d.connection
})
document.getElementById("btn").onclick = function(e){
chan.call("update",this,[{chr:"chr2",start:10000,end:50000}])
}
chan.on("update",function(d){
document.getElementById("message").innerHTML = JSON.stringify(d)
})
})()
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment