Connecting and reusing DOMWidgetModel/View code within a Widget

Hi! I’ve been trying to refactor a DOMWidgetModel and DOMWidgetView pair to make something I can view as a Widget at the top-level. But, I’m running into questions about the best way to store model attributes and the like, and how to avoid reimplementing a large amount of code between the two.

Is there a good example of something like this out there, that someone could recommend? It seems like the kind of thing that has likely been done before, but my searching and browsing hasn’t turned up any canonical examples.