gloo

repository·master·Indexed 24 days ago

https://github.com/ranile/gloo

A modular toolkit of Rust libraries providing ergonomic wrappers for browser APIs to make WebAssembly development more productive and idiomatic. It includes crates for console logging (gloo-console), dialogs (gloo-dialogs), event listeners (gloo-events), files and blobs (gloo-file), history (gloo-history), HTTP and WebSockets (gloo-net), requestAnimationFrame (gloo-render), web storage (gloo-storage), timers (gloo-timers), and web workers (gloo-worker).

Tokens
27.4K
Snippets
70
Records
185
Agent score
82%

What's inside gloo

  1. What is Gloo?

    master

    Gloo is a modular toolkit consisting of a collection of libraries that provide ergonomic Rust wrappers for browser APIs. It is designed to bridge the gap between the raw, often difficult-to-use web-sys and js-sys bindings and the idiomatic, high-level patterns expected in Rust development.

    Because it is a toolkit rather than a monolithic framework, you can use the entire collection to build a full Web application, or you can pick and choose individual utility crates to integrate small, targeted Wasm modules into existing JavaScript projects.

  2. Overview of gloo-utils

    master
    gloo-utils is a utility crate within the Gloo ecosystem designed to wrap common web_sys features. It provides a cleaner, more ergonomic API for interacting with Web APIs in Rust/WebAssembly applications, abstracting away some of the verbosity of the underlying web_sys bindings.
  3. Overview of Gloo Workers

    master
    Gloo workers provide an abstraction over the browser's Web Workers API, allowing you to offload tasks to web workers that run concurrently. This abstraction can be consumed from anywhere in your Rust/WebAssembly application to prevent heavy computations from blocking the main thread.
  4. Offload tasks to web workers with gloo-worker

    master
    Gloo workers provide an abstraction over the browser's Web Workers API, allowing you to offload tasks to run concurrently in the background. This is useful for heavy computations or tasks that should not block the main UI thread. The library uses the standard web-workers API under the hood.
  5. Use gloo-net for HTTP and WebSocket requests in WASM

    master

    The gloo-net crate provides idiomatic Rust bindings for web APIs specifically designed for WebAssembly (WASM) applications. It serves as a high-level wrapper for two primary browser APIs:

    • HTTP: Complete wrappers around the browser's fetch API for making network requests.
    • WebSocket: Complete wrappers around the browser's WebSocket API, utilizing Rust futures for asynchronous communication.

    Use gloo-net when you need to perform standard web networking tasks within a Rust-based WASM application.

  6. Use gloo-dialogs for browser dialogs

    master
    The gloo-dialogs crate provides an idiomatic Rust wrapper for standard Web API dialog functions that are otherwise difficult to use via the raw web-sys crate. It allows you to easily trigger browser-native dialogs for alerting, confirming, and prompting users.
  7. Use gloo-history for History API wrappers

    master
    The gloo-history crate provides high-level Rust wrappers for the Web History API. It allows you to interact with the browser's history stack (e.g., navigating, pushing state, and listening to popstate events) in a type-safe manner within WebAssembly applications.
  8. Use `gloo-events` for easier event listeners

    master
    The gloo-events crate simplifies working with event listeners in WebAssembly by providing the EventListener type. This abstraction makes it significantly easier to manage event listeners compared to using web-sys directly, as it handles the complexities of attaching and managing listeners for you.
  9. Use gloo-file for working with files and blobs on the Web

    master

    The gloo-file crate provides Rust APIs for interacting with files and blobs in a WebAssembly environment. It offers two distinct programming styles to suit different needs:

    1. Callback style: Directly mimics the standard JavaScript File and Blob APIs, which is useful when you want to follow existing web patterns.
    2. Future API: Provides an asynchronous interface using Rust's Future trait, allowing you to use async/await syntax for file operations.
  10. Use gloo-render to wrap requestAnimationFrame

    master
    The gloo-render crate provides a Rust wrapper for the browser's requestAnimationFrame API. This allows you to schedule code execution to run before the next repaint, which is essential for smooth animations in WebAssembly applications.