Published
Edited
Oct 2, 2019
2 stars
Insert cell
Insert cell
Insert cell
value
Insert cell
{
var socket = new WebSocket("wss://ws.blockchain.info/inv");
invalidation.then(() => socket.close())
socket.addEventListener("open", () => socket.send(JSON.stringify({op: "unconfirmed_sub"})))
socket.addEventListener("message", message =>
set(JSON.parse(message.data).x.inputs[0].prev_out.value / 100000000))
socket.addEventListener("message", message =>
btc$.next(JSON.parse(message.data).x.inputs[0].prev_out.value / 100000000))
}
Insert cell
btc$ = new rx.Subject()
Insert cell
btc$.value()
Insert cell
rate$ = obs.interval(2000)
.flatMap( x => get$('https://blockchain.info/ticker'))
.pluck('CHF')
.pluck('last')
Insert cell
rate$.value()
Insert cell
chf$ = btc$.withLatestFrom(rate$, (btc,rate) => btc * rate)
Insert cell
format = new Intl.NumberFormat('de-CH', { style: 'currency', currency: 'CHF' }).format
Insert cell
chf$.scan( (x,y) => x+y).map(format).map(x => html`Transaction Volume: <b>${x}`).value()
Insert cell
chf$.scan( Math.max ).map(format).map(x => html`Largest Transaction: <b>${x}`).value()
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more