-
Notifications
You must be signed in to change notification settings - Fork 19
/
index.js
31 lines (24 loc) · 1023 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// @ts-check
// Web example with REV transfer and balance check
import { pageLog, handleHashHref } from './controls/common'
import { makeRNodeWeb } from '../rnode-web'
import { makeRNodeActions } from './rnode-actions'
import { startApp } from './controls/main-ctrl'
// DOM global functions / dependencies
const { log: logOrig, warn } = console
const { fetch } = window
// Prevents default redirect for link <a href="#">
handleHashHref(document.body)
// Page printer mirrors the console `log`
const log = pageLog({log: logOrig, document})
// Make RNode web API client / wrapped around DOM fetch
const rnodeWeb = makeRNodeWeb({fetch})
// Make application actions as a wrapper around RNode API
const appNodeEff = makeRNodeActions(rnodeWeb, {log, warn})
// Application root element
const appRoot = document.querySelector('#app')
// Attach to window load event (to refresh on duplicated tab)
window.addEventListener('load', ev => {
// Start main app / supply effects
startApp(appRoot, {...appNodeEff, log, warn})
})