Thread
#stdlib
    Brendan Campbell-hartzell

    Brendan Campbell-hartzell

    1 year ago
    This may be getting into the multiple receivers feature, but I'm wondering if there's a way to do this without having to wrap the IComponent in a with() call or something similar.
    The goal here being that I'm enforcing all the properties of the IComponent to only be accessed and modified within the context of a GUIUpdate.
    r

    Roukanken

    1 year ago
    The only way to do it rn, is to declare
    var IComponent.description: String
    within
    GUIUpdate
    (also, might be better to call it GuiUpdate) Which probably isnt a maintanable model, as GuiUpdate will get bloated Currently, Kotlin differs between "implicit" (this) and "explicit" (stuff before
    .
    ) recievers - and if you specify explicit reciever, then it cannot mean an implicit one in definition - so the
    vm.description
    can only call: a) stuff without reciever defined in IComponent b) stuff that has IComponent as explicit receiver in definition And yes, this would most likely be easier with multiple recievers, as smth like
    interface IComponent : ViewModel {
        
        @with(GuiUpdate)
        var description: String
    }
    Would likely work exactly as you want to. (I'm making a lot of assumptions there tho)
    Brendan Campbell-hartzell

    Brendan Campbell-hartzell

    1 year ago
    Yeah. I mean, it isn't too painful to wrap it in a
    with,
    apply
    , or
    run
    , but it isn't as discoverable on the client side.