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)
- Svelte 5: optimise prop access
- Regression: Silence ownership warning for object class fields HOT 4
- [Error] undefined is not an object (evaluating 'if_block.p') HOT 1
- Svelte 5: $derived doesn't update if $state is created and read outside of a reactive context
- Svelte 5: Sub-object losing reactivity HOT 3
- Support for XML serialization of HTML5 HOT 1
- Parenthesized sequences not allowed in element attributes
- Svelte 5: svelte:element with its `this` set to `input` or `textarea` doesn't call their actions HOT 8
- Svelte 5: Classes after dynamic expression in class attribute lost in SSR HOT 2
- Svelte 5 doesn't produce the last tween value in transitions
- Svelte 5: `<script>` tag doesn't load conditionally
- Svelte 5: Misleading error message "Cannot reassign or bind to each block argument in runes mode." HOT 2
- Svelte 5: event handler doesn't get passed when passing all spread props HOT 2
- Svelte 5: Bug - ReferenceError occurs when defining a snippet inside a script along with bind:value in SSR mode. HOT 2
- Hub of all components? HOT 1
- The input element should include `camera` as a possible argument for the `capture` attribute HOT 2
- Svelte 5: Function calls in markup not being memoized when located in adjacent text nodes HOT 1
- Svelte 5 - $dervied causes svelte-check errors that do not occur with $derived.by HOT 4
- svelte:head rendering problem with 5:Runes HOT 1
- Unexpected rendering of some markdown content (documentation, blog)
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.