In my connect() function (which is a singleton), right after connecting I execute the device.connect.listen block that is in the FBP documentation. I pass a callback function as a parameter to my connect() function and within the listen block, I check the state and if it is "disconnect", I call cancel(), then invoke my callback function. Within the callback function I can do anything I want; snackbar, alert dialog, ...