Q:

listen for device changes using API state did change

Im am using Mbient Lab API to talk to a device.  Using the api I discovered there is a stateDidChange Variable that looks like this: 
var stateDidChange: (() -> Void)? {  get set }
How would I use this method in viewcontroller to detect a change in the device (such as another device has connected to it already) or can someone provide documentation on what this variable does.  Link to the API is https://mbientlab.com/documents/metawear/ios/latest/Classes/ScannerModelItem.html

A:

Simply assign a block to stateDidChange and handle your logic inside that block. 
let item = ScannerModelItem()
item.stateDidChange = {
   // Handle state change
}

