I finally managed to get custom components working for me after many failed attempts (and some help from Victoria
This post may help:
The main thing is using the window.Retool.subscribe function (see example). I put absolutely everything into that function, I'm sure you could make it more elegant but it's simple and it worked.