38 lines
912 B
Markdown
38 lines
912 B
Markdown
# framerock
|
|
|
|
*JS framework for rad web apps*
|
|
|
|
a minimal example:
|
|
|
|
```javascript
|
|
import { async_run } from 'framerock'
|
|
|
|
const jsbuild_app_frontend = async function () {
|
|
return `
|
|
const on_open = function () {
|
|
FRAMEROCK_UTILS.transport_send_bytes(new TextEncoder().encode('Hello from client!'))
|
|
return
|
|
}
|
|
const on_message = function (data) {
|
|
console.log(['Client received message:', new TextDecoder().decode(data)])
|
|
return
|
|
}
|
|
FRAMEROCK_UTILS.setup_transport({ on_open, on_message })
|
|
`.trim()
|
|
}
|
|
|
|
const handle_transport_bytes = function (utils, message) {
|
|
console.log(['Server received message:', new TextDecoder().decode(message)])
|
|
utils.transport_send_bytes(new TextEncoder().encode('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)
|
|
```
|
|
|