Labels

To allow more complex access across different data stores, labels are supported. In other words, you can name state containers and then access them where you need. The feature is comparable to React context and the use case is similar.

x-label

x-label gives access to parent state and it’s useful for sharing information between scopes.

Editor

  

Setting parent state from a child

It’s also possible to set the parent state from a child. This allows you to nest state within state while being able to mutate it.

Editor

  
Parent state in between:
Parent state:
Child state:

Nested labels

The nested behavior works for attributes as well.

Editor

  
Parent
Child

Labels during iteration

The labeled data is available at x-each as well:

Editor

  

Deriving state

State can also be derived to compose or enhance it.

Editor

  
Value:
Value:

JavaScript API

The same works with the JavaScript API.

Editor

  
Value:
Value:

Multiple labels at once

Also multiple labels are supported.

Editor