From fc9d4673cf5abd536e0996737b4f8820c7628061 Mon Sep 17 00:00:00 2001 From: dab Date: Fri, 15 Aug 2025 14:42:46 +0000 Subject: [PATCH] updated README.md to include minimal example of usage --- README.md | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7a0a19e..6364b78 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,39 @@ # 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) +``` +