The state
-capability provides a way to get and update the state of a thing. State is split into several state keys that are updated separately.
js
- if(thing.matches('cap:state')) {
console.log('Current state:', this.state);
}
The state
-capability has no functions that need to be implemented. updateState
can be called at any time to update a state key.
js
const { Thing, State } = require('abstract-things');
- class Example extends Thing.with(State) {
- constructor() {
super();
this.updateState('key', true);
}
}