Coder Social home page Coder Social logo

Comments (5)

GreenAsJade avatar GreenAsJade commented on September 4, 2024 1

In general, I think this ticket is aimed at code like this

    const [variation_stone_transparency, _setVariationStoneTransparency] = usePreference(
        "variation-stone-transparency",
    );

    function setVariationStoneTransparency(ev) {
        const value = parseFloat(ev.target.value);

        if (value >= 0.0 && value <= 1.0) {
            _setVariationStoneTransparency(value);
        }
    }

... where the correct function to call to set the value is setVariationStoneTransparency, then the underlying preference setter should be preceded by _

As Andy commented - "a common pattern in Prefs, but possibly elsewhere"

from online-go.com.

GreenAsJade avatar GreenAsJade commented on September 4, 2024 1

I think the gist of this ticket was "there's meaning behind the scheme, but it's inconsistently applied, so a first-time coder could get to know the code and make it applied consistently"

from online-go.com.

anoek avatar anoek commented on September 4, 2024

Well, what's here is the expectation that for a given state/preference xyz there exists a corresponding function setXyz that changes that value. In the case where we need some extra logic, we provide setXyz as the function we use, but we have _setXyz that that function calls after doing whatever special logic it needs. In this case, having the _setXyz is "internal" in the sense that it is not meant to be directly called by ourselves, but it remains very clear that that is the actual setter, but that we should be using setXyz.

from online-go.com.

anoek avatar anoek commented on September 4, 2024

Closing as "there's meaning behind the scheme and we like it as is" :)

from online-go.com.

anoek avatar anoek commented on September 4, 2024

In that case, open for business!

from online-go.com.

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.