Comments (6)
yep
from svelte.
I would welcome this, have never like two-way binding.
from svelte.
I like two-way binding when I want it. Here's a scenario that I often run into:
I have an edit form. I want it to edit a copy, and only commit the edits when the user saves. I want 2-way binding on that copy, but it shouldn't update the original (in some global array somewhere).
The way I like to do this is to pass the original into my form component, and in my form component's initialize method, I create a copy of the data.
It would be nice to be able to access the passed-in values in a components data method:
import UserCard from './user_card.html';
export default {
data(params) {
return {
tmp: copyObject(params.user)
}
},
components: {UserCard}
}
This would be really handy.
from svelte.
As a followup to my last comment, this seems to work pretty well for getting a tmp
property that is a copy of a the user object:
computed: {
tmp: user => {
return Object.assign({}, user);
}
},
from svelte.
When I use Redux with Ractive, I disable two-way binding to avoid accidentally mutating state. If/when I hook up Redux to Svelte, I imagine I'd want the same option.
from svelte.
Is this literally requesting an option to disable the bind:
directive?
from svelte.
Related Issues (20)
- 5.0.0-next.227: Reading $state in script tags does not return the current value if the variable is not referenced outside of script tags HOT 5
- Transition doesn't play when state updated inside onscroll handler
- svelte set bound property to undefined when destroy the list component HOT 1
- Svelte 5 RollupError: Illegal reassignment of import
- Advanced search for unused css classes using types HOT 3
- Custom element: event.currentTarget keeps being #shadow-root (document-fragment) while propagating outside once svelte handles the event
- children in await+each blocks ignore transitions HOT 2
- Errors after context="module" to module change in Svelte 5 HOT 9
- [AST] Incorrect parsing of comments inside the callback scope HOT 2
- Svelte style props for content: "" not working properly? HOT 2
- Localization support via the svelte compiler. HOT 9
- Unexpected results using `$effect` & `untrack` (circular dependecy) HOT 6
- Svelte 5: Transitions cause errors when the state changes frequently HOT 2
- svelte5: Better error message for binding to undefined variables HOT 3
- Svelte5 : Support for bracket notation in dynamic component rendering HOT 2
- Svelte 5 Reactivity issue with Svelte 4 code HOT 4
- Svelte 5: state_unsafe_local_read broken my project HOT 1
- Reactivity problem with objects/arrays in some case (toString) HOT 3
- feat: svelte/server render to have inject css option separate from global config HOT 2
- New root component doesn't work with Map HOT 4
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 svelte.