GithubHelp home page GithubHelp logo

Comments (1)

vovgou avatar vovgou commented on July 24, 2024

现在的DataBinding,只能绑定某个变量,到某个数据上;

然而,有些时候,ViewModel的副作用可能难以通过简单的View层变量更新体现,而需要更多复杂的处理

因此,我希望BindingSet加入回调绑定的功能,样例写法如下:

void OnVarChanged(int val);
Bind(OnVarChanged).To(vm->x);

Besides:响应式数据这块,是否有可能参考Vue/React的写法,实现useEffect这样复杂的监听Hook?

首先,Unity的UnityEvent 是可以绑定到ViewModel上的一个函数的。
然后你这里提到的这种情况,想将ViewModel的一个属性改变绑定到View层的一个函数上,你这个设计是不合理的,View里面应该就是一个简简单单的数据绑定,不应该在有这些逻辑。你应该通过自定义控件的方式来支持你这种需求。

参考我的ListView、或者我扩展的OSA的Grid、List等组件,还有FormattableTextMeshPro,TemplateTextMeshProUGUI。

这个道理跟 UGUI的Slider一样,我用户只关注value属性,还要滑动条最大最小值,业务逻辑只修改value属性,至于你里面还要同步更新多少值,要做多少事,那是Slider的工作,不能放在View中去做

from loxodon-framework.

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.