This API Overview highlights some of the the Zaplib Standard Library. Our API Reference is is more comprehensive but isn't as user friendly.
Some Rust functions, particularly around IO, don't work in WebAssembly out-of-the-box. Zaplib provides a number of cross-platform, "universal" interfaces that work both natively and in WebAssembly.
|Logs to the console (with line number).|
Cx object. This is a global "context" object, that gets passed around practically everywhere.
When the app is constructed, a
Construct event is fired. It is fired exactly once, and before any other calls to
draw. The event contains no further information.
cx.start_timer creates a new
Timer object. When the timer fires, a
TimerEvent event is dispatched. Use
timer.is_timer to check if that event belongs to a particular timer. Use
cx.stop_timer to stop it.
Signals are user-defined events that can be used for anything you want. Create a new
Signal object by calling
cx.new_signal. Then send it with a
cx.send_signal (same thread) or
Cx::post_signal (any thread). This will trigger a
SignalEvent on the main thread (
draw are always called on the main Rust thread).
Note that the Signals API is a bit complicated currently; we aim to improve this so you can send any user-defined events.
To create a drop target for the entire window / browser tab, we have to create a
create_add_drop_target_for_app_open_files. Then, when dropping a file, an
AppOpenFilesEvent event will fire.
Some standard library APIs don't work in all contexts. APIs that are currently unsupported in a context are annotated with a tracking ticket ID.
|API||Rust main thread||Rust child thread||JS main thread||JS WebWorker|
|Spawning threads (||✅||✅||#72||#72|
|Current time (||✅||✅||✅||✅|
|Reading local files (||✅||✅||#72 #66||#72|
|Writing local files||#73||#73||#73 #66||#73|
|HTTP requests (||✅||✅||#66||✅|
|Posting signals (||✅||✅||#72||#72|
|Blocking Rust threading primitives (||✅||✅||#66||✅|