jeudi 17 janvier 2019

update the state of component from another component

I have a class

class TableComponent {
    tableBody
    tableHeader
    tableFooter
}

TableHeader has a button that should be enabled or disabled depending on the state of tableBody

class TableHeader {
    button

    void enableButton(false|true)
}

To handle this I pass instance of TableHeader to TableBody like this

new TableBody(tableHeader);

and inside the tableBody I do some actions and invoke tableHeader.enableButton()

But is there a way not to pass the reference of tableHeader into the body? Would use for example of EventBus better? Or for join all table classes into a single class?

Aucun commentaire:

Enregistrer un commentaire