Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
LazySignals for Bevy
An ad hoc, informally-specified, bug-ridden, kinda fast implementation of 1/3 of MIT-Scheme.
Primitives and examples for implementing a lazy kind of reactive signals for Bevy.
WARNING: This is under active development and comes with even fewer guarantees for fitness to purpose than the licenses provide.
Credits
The initial structure of this project is based on bevy_rx.
Architecture
This library is basically Haskell monads under the hood with a TC39 Signals developer API inspired by ECMAScript so-called reactive libraries. It is also influenced by the MIT Propagator model. Well, at least a YouTube video that mentions it.
See also in-depth Architecture and Rationale
Design Questions
- What's a good way to handle errors?
- Can this work with
futures_lite
to create afutures-signals
-like API? - During initialization, should computed and effect contexts actually evaluate?
- How to best prevent or detect infinite loops?
- Can the use of get vs unwrap be more consistent?
- ✔️ Should
Tasks
be able to renember they were retriggered while still running and then run again immediately after finishing? (I think they currently do) - ✔️ Should there be an option to run a Bevy system as an effect?
- Should there be a commands-only version of effects?
- Do we need a
useRef
equivalent to support state that is not passed around by value? - Same question about
useCallback
- ❌ Can change detection replace some of the components we currently add manually?
- Can a
Computed
and anEffect
live on the same entity? (Technically yes, but why?) - Do we want an API to trigger an
Effect
directly? - Should there be a way to write closures that take the result struct and not
Option
? - How to send a
DynamicStruct
as a signal? Doesn't work now due toFromReflect
bound. - ✔️ Lots of reactive libraries distinguish
Actions
fromEffects
. ShouldAsyncTask
be renamed toAction
?
TODO
Missing
- Testing
- Error handling and general resiliency
Enhancements
- See if there is a way to register effect systems during init and retain
SystemId
- More API documentation
- I need someone to just review every line because I am a total n00b
- More examples, including basic game stuff (gold and health seem popular)
- More examples, including some integrating
LazySignals
with popularBevy
projects such asbevy-lunex
,bevy_dioxus
,bevy_editor_pls
,bevy_reactor
,haalka
,kayak_ui
,polako
,quill
,space_editor
, etc.
Stuff I'm Actually Going To Do
- Define bundles for the signals primitives
- Support
bevy_reflect
types out of the box - Add async task management for effects
- Prevent retrigger if task still running from last time
- Process tasks to run their commands when they are complete
- Make sure
Triggered
gets removed fromComputed
s during processing - Remove
Clone
fromLazySignalsData
trait bounds - Implement effect systems
- Integrate with
bevy_mod_picking
- Make a demo of a fully wired
sickle_ui
entity inspector - Make sure we can convert the result struct into a regular
Option<Result<>>
- Find a better way to manage the Effect systems (at init time)
- See if there is a way to schedule a system using an Action's CommandQueue
- Provide integration with Bevy observers
- Add getter/setter tuples factory to API (may need macros)
- Add Source fields for sources Vecs
- Support undo/redo
- Integrate with bevy-inspector-egui
- Do the Ten Challenges
- Support streams if the developer expects the same signal to be sent multiple times/tick
- See how well the demo plays with bevy_mod_scripting
- Write a bunch of Fennel code to see how well it works to script the computeds and effects
- Make a visual signals editor plugin
- See how well the demo plays with aery
- Prevent or at least detect infinite loops
General Usage
The LazySignalsPlugin will register the core types and systems.
Create signals, computeds, effects, and tasks with the API during application init. Read and send signals and read memoized computeds in update systems. Trigger actions and effects when source or trigger signals are sent or source computeds change value.
For basic usage, an application specific resource may track the reactive primitive entities.
(see basic_test for working, tested code)
use *;
use ;
;
🕊 Bevy Compatibility
bevy | bevy_lazy_signals |
---|---|
0.14.0 | 0.4.0-alpha+ |
0.13.2 | 0.3.0-alpha |
License
All code in this repository is dual-licensed under either:
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
at your option. This means you can select the license you prefer.
Your contributions
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.