Two Way Binding
Observers can also be bound bi-directionally, in which case an element can both send and receive updates through its observer. The following example shows a two way binding between two text inputs, where either input can update the value of the other. It's been written in React to showcase binding with React components.
How To
First import the components, binding classes and PCUI styles.
import { Observer } from '@playcanvas/observer';
import { TextInput, BindingTwoWay } from '@playcanvas/pcui';
import '@playcanvas/pcui/styles';
Then create a new observer for a an object which contains a text string.
const observer = new Observer({
text: 'Hello World'
});