Co-authored-by: Tim Mecklem <timothy@mecklem.com>pull/333/head
parent
3a50823ef5
commit
259fce7580
@ -0,0 +1,16 @@ |
||||
import $ from 'jquery' |
||||
import socket from '../socket' |
||||
|
||||
if (window.page === 'address') { |
||||
const channel = socket.channel(`addresses:${window.addressHash}`, {}) |
||||
channel.join() |
||||
.receive('ok', resp => { console.log('Joined successfully', `addresses:${window.addressHash}`, resp) }) |
||||
.receive('error', resp => { console.log('Unable to join', `addresses:${window.addressHash}`, resp) }) |
||||
|
||||
const $transactionsList = $('[data-selector="transactions-list"]') |
||||
if ($transactionsList) { |
||||
channel.on('transaction', (msg) => { |
||||
$transactionsList.prepend(msg.transaction) |
||||
}) |
||||
} |
||||
} |
@ -1,21 +1,6 @@ |
||||
import {Socket} from 'phoenix' |
||||
import $ from 'jquery' |
||||
|
||||
let socket = new Socket('/socket', {params: {locale: window.locale}}) |
||||
const socket = new Socket('/socket', {params: {locale: window.locale}}) |
||||
socket.connect() |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// addresses channel
|
||||
let channel = socket.channel(`addresses:${window.addressHash}`, {}) |
||||
channel.join() |
||||
.receive('ok', resp => { console.log('Joined successfully', resp) }) |
||||
.receive('error', resp => { console.log('Unable to join', resp) }) |
||||
|
||||
channel.on('transaction', (msg) => { |
||||
$('[data-selector="transactions-list"]').prepend(msg.transaction) |
||||
}) |
||||
|
||||
export default socket |
||||
|
Loading…
Reference in new issue