Conversation
Co-Authored-By: Staging-Devin AI <166158716+staging-devin-ai-integration[bot]@users.noreply.github.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New workspace crate
refract(publish = false): a from-scratch Dioxus-like reactive runtime built around stores and lenses, inspired by ealmloff/qk. Seerefract/DESIGN.mdfor the full rationale — especially the memo/resource design.Core model:
Store<T>roots live in a thread-local generational slab; each value is aBox<RefCell<dyn Any>>, so guards are zero-copyRef/RefMutprojections (Ref::map) — no clones, noRc<T>per field.Lens/IndexLenscompose over anyReadable, carrying a structural path (Vec<u32>). Invalidation uses path-prefix overlap: writingstore.fieldwakes readers offieldand of the whole store, but not sibling fields;todos[3]doesn't waketodos[4].RwTrack-style:ReadGuard::derefsubscribes;WriteGuard::deref_mutflags the write, and notification happens on guard drop after releasing theRefMut. AWriteGuardthat is onlyDeref'd never notifies.Memo (
Clean/Check/Dirtywith version counters):Dirtyto direct subscribers andChecktransitively;ensure()walks deps and only recomputes when a dep's version actually changed.!=old, so diamond graphs cut off.ReadGuard, so recomputation never needs&mutwhile a lens guard into the memo is live. Cycles panic deterministically (computingflag), and holding a guard across a write to the same cell is a deterministicRefCellpanic, never UB.Resource (the Pin-sensitive part):
ResourceState<T>:Pending/Ready/Reloading) and the driverPin<Box<dyn Future<Output = ()>>>are stored separately — polling needs&muton the future while lenses may holdRefs on the state, and the future may be self-referential after first poll so it is never moved out of its box.Reloading(T), and spawn a new one. Only reads in the synchronous source closure are tracked.Also: eager
Effects with ownership scopes (children/deps torn down on rerun, queue processed shallowest-first so parents dispose stale children), a minimal retained DOM (el/text/dyn_text/dyn_attr/dyn_childrenbound via effects, no VDOM), 15 integration tests, andcounter/todos/weatherexamples.Verification
cargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo test --workspace --all-targets --all-features(15 refract integration tests) andcargo test -p refract --docRUSTDOCFLAGS=-Dwarnings cargo doc --no-deps --all-features -p refractcargo run -p refract --example counter|todos|weatherLink to Devin session: https://dioxus.staging.devinenterprise.com/sessions/edc42af2e89248a280abfa6508da3a43
Requested by: @ealmloff