Skip to content

Commit 35b7bce

Browse files
committed
Add asynchronous binding replies
1 parent 526ae68 commit 35b7bce

4 files changed

Lines changed: 257 additions & 8 deletions

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ The current phase provides:
1313
built-in JavaScript bridge;
1414
- JavaScript calls to Zig bindings with return values;
1515
- typed integer, float, and boolean call arguments and replies;
16+
- owned one-shot delayed binding replies through `Call.deferReply()`;
1617
- window and targeted `Call.client` calls to JavaScript with results, errors,
1718
timeouts, and stale-client detection;
1819
- targeted client navigation, close, and raw binary delivery;
1920
- bounded multi-client windows through `WindowOptions.max_clients`;
2021
- bounded concurrent evaluations through
2122
`WindowOptions.max_pending_evals`;
23+
- bounded delayed replies through `WindowOptions.max_pending_replies`;
2224
- explicit connection, WebSocket message, call, argument, binding, event, and
2325
script limits through `App.Options.limits`;
2426
- window navigation, close, raw-data, and JavaScript broadcasts with
@@ -107,6 +109,12 @@ Navigation attempts are intercepted while an event handler is installed; call
107109
handlers receive no arguments and their replies are ignored; explicit
108110
`webui.call("button", ...)` remains available.
109111

112+
Binding handlers can transfer an explicit `webui.call()` response beyond the
113+
handler lifetime with `Call.deferReply()`. Complete the owned `PendingReply`
114+
once with `reply()`, `replyInt()`, `replyFloat()`, or `replyBool()`, or call
115+
`deinit()` to abandon it. All pending replies must be completed or abandoned
116+
before `App.deinit()`.
117+
110118
The browser-side `webui` object also provides connection events, runtime
111119
logging, Base64 helpers, navigation control, and native high-contrast media
112120
query detection.

docs/PURE_ZIG_REFACTOR.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,6 @@ implementations.
298298
| `webui_show()`, `webui_set_root_folder()`, `webui_set_file_handler()`, `webui_set_file_handler_window()` | Content and resource handling can only be selected when creating a window; replacing them at runtime is not implemented. |
299299
| `webui_show_client()` | `Client` cannot replace the content of only one connected browser. |
300300
| `webui_is_shown()` | There is no window-level connected/shown query. |
301-
| `webui_set_config(asynchronous_response)` | A `Call` response must be completed during the binding handler lifetime. |
302301
| `webui_set_config(show_wait_connection)`, `webui_set_timeout()` | `Window.open()` does not optionally wait for a browser connection. |
303302
| `webui_set_config(ui_event_blocking)`, `webui_set_event_blocking()` | Per-window event scheduling control is not exposed. |
304303
| `webui_set_config(folder_monitor)` | Directory change monitoring and automatic browser reload are not implemented. |
@@ -343,6 +342,7 @@ not implementation gaps:
343342
| `webui_get_count()`, `webui_get_size()`, `webui_get_size_at()` | `Call.arguments.len` and `Call.bytes(index).len`. |
344343
| `webui_get_string()`, `webui_get_string_at()`, `webui_get_int()`, `webui_get_int_at()`, `webui_get_float()`, `webui_get_float_at()`, `webui_get_bool()`, `webui_get_bool_at()` | `Call.string()`, `Call.int()`, `Call.float()`, and `Call.boolean()`. |
345344
| `webui_return_string()`, `webui_return_int()`, `webui_return_float()`, `webui_return_bool()` | `Call.reply()`, `Call.replyInt()`, `Call.replyFloat()`, and `Call.replyBool()`. |
345+
| `webui_set_config(asynchronous_response)` | `Call.deferReply()` transfers the response to a bounded, owned, one-shot `PendingReply`. |
346346
| `webui_run()`, `webui_script()` | `Window.run()` and `Window.eval()`. |
347347
| `webui_run_client()`, `webui_script_client()` | `Client.run()` and `Client.eval()`. |
348348
| `webui_close_client()`, `webui_navigate_client()`, `webui_send_raw_client()` | `Client.close()`, `Client.navigate()`, and `Client.sendRaw()`. |
@@ -385,7 +385,6 @@ methods, and the public browser bridge surface.
385385

386386
### Handler and event lifecycle
387387

388-
- Add an owned delayed-response handle for asynchronous binding responses.
389388
- Add per-window serialized or concurrent event execution.
390389
- Add optional wait-for-connection behavior and a connection timeout.
391390
- Add a caller-provided logger.
@@ -494,7 +493,6 @@ zig build -Dtarget=aarch64-macos
494493

495494
Continue capability parity:
496495

497-
1. Add an owned delayed-response handle for asynchronous binding responses.
498-
2. Add per-window event scheduling control.
499-
3. Add optional wait-for-connection behavior and a connection timeout.
500-
4. Add a caller-provided logger.
496+
1. Add per-window event scheduling control.
497+
2. Add optional wait-for-connection behavior and a connection timeout.
498+
3. Add a caller-provided logger.

0 commit comments

Comments
 (0)