Giter Site home page Giter Site logo

Comments (6)

Rich-Harris avatar Rich-Harris commented on May 20, 2024 2

yep

from svelte.

proyb6 avatar proyb6 commented on May 20, 2024 1

I would welcome this, have never like two-way binding.

from svelte.

chrisdavies avatar chrisdavies commented on May 20, 2024 1

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.

chrisdavies avatar chrisdavies commented on May 20, 2024

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.

TehShrike avatar TehShrike commented on May 20, 2024

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.

PaulBGD avatar PaulBGD commented on May 20, 2024

Is this literally requesting an option to disable the bind: directive?

from svelte.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.