updated README.md to include minimal example of usage
This commit is contained in:
parent
59d83d7857
commit
fc9d4673cf
1 changed files with 37 additions and 1 deletions
38
README.md
38
README.md
|
@ -1,3 +1,39 @@
|
||||||
# framerock
|
# framerock
|
||||||
|
|
||||||
JS framework for rad web apps
|
*JS framework for rad web apps*
|
||||||
|
|
||||||
|
a minimal example:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
import { async_run } from 'framerock'
|
||||||
|
|
||||||
|
const jsbuild_app_frontend = async function () {
|
||||||
|
const str_js = `
|
||||||
|
const on_open = function () {
|
||||||
|
FRAMEROCK_UTILS.transport_send_bytes('Hello from client!')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const on_message = function (data) {
|
||||||
|
console.log(['Client received message:', data])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
FRAMEROCK_UTILS.setup_transport({ on_open, on_message })
|
||||||
|
`.trim()
|
||||||
|
return str_js
|
||||||
|
}
|
||||||
|
|
||||||
|
const handle_transport_bytes = function (utils, message) {
|
||||||
|
console.log(['Server received message:', message])
|
||||||
|
utils.transport_send_bytes('Hello from server!')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
hostname: '0.0.0.0',
|
||||||
|
port: 8800,
|
||||||
|
page_title: 'framerock demo',
|
||||||
|
}
|
||||||
|
|
||||||
|
async_run({ config, jsbuild_app_frontend, handle_transport_bytes }).then(()=>{}).catch(console.error)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue