Skip to content

Latest commit

 

History

History
88 lines (56 loc) · 1.98 KB

state.rst

File metadata and controls

88 lines (56 loc) · 1.98 KB

cap:state - state tracking

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);

}

API

Events

Protected methods

Implementing capability

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);

}

}