market_summaries = Generators.observe(notify => {
let state = {};
const channel = socket.channel('/subscription:market_summaries;86400')
channel.join()
.receive('ok', () => {
channel
.push('request', {timestamp: new Date() * 1000})
.receive('ok', ({data: [d]}) => {
state = createState(state, d.data)
notify(state)
})
})
.receive('error', () => console.log('join error'))
channel.on('notification', ({data: [d]}) => {
state = createState(state, d.data)
notify(state)
})
return () => channel.leave()
})