Moving from components to composable functions
So far, I explained the word component by saying that it refers to UI elements. In fact, the term is used in quite a few other areas. Generally speaking, components structure systems by separating distinct portions or parts of them. The inner workings of a component are typically hidden from the outside (known as the black box principle).
Tip
To learn more about the black box principle, please refer to https://en.wikipedia.org/wiki/Black_box.
Components communicate with other parts of the system by sending and receiving messages. The appearance or behavior of a component is controlled through a set of attributes, or properties.
Consider TextView
. We set text by modifying the text
property and we control its visibility through visibility
. What about sending and receiving messages? Let’s look at Button
. We can react to clicks (receive a message) by registering (sending a message) an OnClickListener
instance. The same principle...