Comments (4)
So, since I alluded to it in the previous discussion: The only thing this would really affect is transitions.
The Clone
requirement was originally because I had a use_transition()
like the one in Solid or React, implemented in a way that required you to be able to clone the existing value. Basically, transitions "fork" reality so that the reactive system keeps moving along and updating "under transition" but not actually updating the UI until all the asynchronous work being done is complete. This does require T: Clone
because you need to clone value
to get transition_value
.
This isn't necessary for something like our <Suspense/>
, and in fact I've removed it because my implementation was buggy anyway. It enables some nicer UI for things like routing, but I'm sure that can be added manually.
I'm very open to removing the Clone
requirement since it's not currently necessary and maybe reimplementing transitions in the future in a different way (or restricting which signals can have transitional values).
from leptos.
Interesting note on the transitions. Based only on your original comment, I had the impression that the Clones were mainly just legacy code that hadn't been removed yet but, if there's a reason they'll be needed in the future, it seems like you might as well keep them. I'd have to take a look at that old transitions implementation to make sure I actually understand what they do/how they do it to give any real feedback I'm afraid.
from leptos.
Re: transitions — If you're reading this (Dan or anyone else) and have no idea what I'm talking about, here's the classic Solid demo: without transitions and with transitions. Transitions are basically a way of "holding" an original state, while asynchronously transitioning to a new state, rather than flashing back to the <Suspense>
fallback.
I've rewritten the reactive system since then, but here's how transitions would basically work in the current reactive system:
- There would be two additional field in
Runtime
: where now we havesignal_values
, there would besignal_t_values
, and there would be arunning_transition: Option<TransitionState>
field to track the transition - Calling
start_transition()
would setrunning_transition = Some(TransitionState::new())
- When we're in a transition, updating a signal would
- clone the signal's value
- apply the mutation to the clone
- keep the original value around
- Effects called "under" the transitional state use the new transitional value; effects called "outside" the transition use the original value
- this includes DOM rendering, which is built entirely on
create_effect
- this includes DOM rendering, which is built entirely on
In the Solid example, it "holds" the value of tab
until the resource for the content has finished loading, then switches tabs. It's entirely possible to get the same UI effect (holding the previous state) as the Solid example manually; what Solid does (and what React does too, although implemented in a very different way) is a way to do this automatically, at the library level.
Given that, I think it makes sense to go ahead and remove the Clone
requirements: at present it's not helping us actually do anything, and causes DX overhead in plenty of cases (see: camera example).
from leptos.
Closed in #37
from leptos.
Related Issues (20)
- Portal strange behavior with reactive children HOT 2
- leptos_config::get_configuration doesn't support workspace metadata in Cargo.toml for multiple projects
- Improve the Documentation on Custom Elements HOT 2
- Multiple ErrorBoundaries break HOT 7
- Add a "create_server_resource" wrapper for server function HOT 1
- Can't pass `Callback` as an event handler
- `memo!` macro similar to `slice!` macro
- Title HOT 1
- 0.7-beta Resource isnt updated with source signal HOT 3
- LocalResource spawn_local called from outside of a task::LocalSet HOT 2
- `0.7-beta` Router `A` component missing `class` & `active_class` props HOT 5
- Path Params not begin passed to nested routes in 0.7 HOT 1
- `0.7-beta` Deeply nested `ParentRoute` does not work with relative routing
- Suspend wrapped LocalResource panics
- True async - Fix or Educate HOT 2
- `0.7-beta` Missing `serde` when using `experimental-islands` and custom props HOT 1
- `0.7-beta` Panic when trying to render nested `island` HOT 4
- `0.7-beta` Nesting an island inside another island's body hydrates the inner island twice HOT 2
- Bump MSRV to 1.8, so we can drop lazy_static
- `0.7-beta` Panic when passing props to `island`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from leptos.