How to call python code after a stroke was drawn in image editor?

How to call python code after a stroke was drawn in image editor?
Is there any kind of callback or handler for this?. Or should I use modal operator for that?