traits icon indicating copy to clipboard operation
traits copied to clipboard

Document that handlers (e.g., `TraitType` subclasses) should be stateless

Open mdickinson opened this issue 1 year ago • 0 comments

I've seen a couple of instances recently where projects were trying to store per-object state in a TraitType instance. That doesn't work, in general: the TraitType instance is per-class, not per-object.

In the section of the user docs on writing your own TraitType subclass, it should be made clear that TraitType instances should be stateless: they shouldn't store per-object state from the HasTraits objects using them.

mdickinson avatar Aug 19 '22 09:08 mdickinson