9 releases
0.2.0 | Jul 1, 2022 |
---|---|
0.1.8 | Apr 28, 2022 |
0.1.7 | Sep 28, 2021 |
0.1.5 | Aug 26, 2021 |
0.1.4 | Jul 28, 2021 |
#424 in WebAssembly
69 downloads per month
Used in percy-preview-app
8KB
app-world

A framework agnostic approach to managing frontend application state.
app-world
is a simple thread-safe storage for application state and resources.
Background
Highly interactive frontend applications need a way to interface with large amounts of application state.
Many frontend frameworks come with state management infrastructure that is coupled to the framework.
app-world
is designed to be used in any frontend application. This makes it well suited those who want to be able to run
their state related logic across multiple target platforms such as the web, mobile and desktop.
With app-world
you have a single World
which holds your application State
, as well your application's Resource
s.
Resource
s are typically used to interface with the outside world, such as to write to a file storage or to make an API request.
You then send Message
s to your world in order to update application state. This is the only way to mutate application state
(with the exception of fields that have interior mutability).
Games
app-world
is designed so that at most one thread can access state at any given time.
This makes app-world
unsuitable for highly stateful real-time games where you'll often want to be able to update state from many threads simultaneously.
If you're working on a game try checking out one of Rust's many entity component system crates.
Example Usage
use app_world::AppWorldWrapper;
struct MyAppWorld {
state: MyAppState,
resources: MyAppResources,
}
struct MyAppState {
count: u32
}
struct MyAppResources {
api_client: Arc<dyn SomeApiClient>
}
enum Msg {
IncrementCount(u8)
}
type MyAppStateWrapper = AppWorldWrapper<MyAppState>;
impl AppWorld for MyAppWorld {
// ...
}
fn main () {
let world = AppWorldWrapper::new(MyAppWorld::new());
world.msg(Msg::IncrementCount);
}
Inspiration
-
The Elm Architecture for the decoupling of views and application state.
-
specs for the
World
State
andResource
names.
No runtime deps
Features
- send
- test-utils