Giter Club home page Giter Club logo

Comments (7)

hi-dhl avatar hi-dhl commented on May 24, 2024

我举个例子,看是否和我理解的一致

    <data>

        <variable
            name="account"
            type="com.hi.dhl.demo.binding.Account" />

    </data>

初始化 DataBinding 的时候,同时给 account 赋值? 我的理解正确吗?

from binding.

br3ant avatar br3ant commented on May 24, 2024

是的,我加了一下,这样传个block进去,便于直接setVariable

inline fun Fragment.databind(noinline block: (ViewDataBinding.() -> Unit)? = null) = FragmentBindingDelegate(this, block)

private val binding by databind {
setVariable(BR.m, playVM)
}

from binding.

hi-dhl avatar hi-dhl commented on May 24, 2024

是的,我加了一下,这样传个block进去,便于直接setVariable

inline fun Fragment.databind(noinline block: (ViewDataBinding.() -> Unit)? = null) = FragmentBindingDelegate(this, block)

private val binding by databind {
setVariable(BR.m, playVM)
}

嗯嗯,如果我的理解是对的话,是可以加上的, 你的这样写法思路是对的,但是有点麻烦,我会在后续的版本加上这个

from binding.

hi-dhl avatar hi-dhl commented on May 24, 2024

但是有个问题咨询一下,你是在什么场景下会用到?

from binding.

br3ant avatar br3ant commented on May 24, 2024

正常场景下都会用到吧,如果不这样写的话,初始化和参数赋值就放在两个地方,而我更喜欢在一个地方把binding的配置弄好,这样在其他地方可以直接使用

from binding.

br3ant avatar br3ant commented on May 24, 2024

我错了,再不需要显示使用databinding的时候,懒加载这种写法会导致参数无法配置上去,而这种情况是比较多的,还是需要手动的去配置

from binding.

br3ant avatar br3ant commented on May 24, 2024

complete v1.0.4 close #3

from binding.

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.