Thank you for your advice! After some troubleshooting I found that the parameter list returned by EVENT_INVENTORY_SINGLE_SLOT_UPDATE does not have
eventcode as described in the documentation, so my addon didn't work as expected before because I wasn't handling the correct parameter. Perhaps the documentation for this needs some updating.
As I said at the beginning, the code I've given is simplified and for demonstration purposes only. I will not use over-generalized event names in the actual addon. Thanks for pointing that out though