It's copied from camera app but I've modified it to support `return value` from `fire/emit` process.