Here's an example used in a widget. The first part is including it in your define function, then you need to carry that variable name into the declare function.
From there, you need to have a function in your widget called "storeState" like this, and you'll of course want to retrieve the state using "getState" like this.