DirtyMixIn
Function: DirtyMixIn()
DirtyMixIn<
T>(clazz):T&Constructor<{[WEBDA_DIRTY]:DirtyState;dirty:DirtyState; }>
Defined in: packages/utils/src/dirty.ts:192
Mixin that adds dirty-tracking to a class via a Proxy.
Every property assignment on the resulting instance is intercepted and
recorded in an internal DirtyState. The dirty getter exposes
the state — returning the DirtyState when modifications exist,
or null when the object is clean.
Type Parameters
T
T extends Constructor<object>
Base class constructor type
Parameters
clazz
T
The class to extend with dirty-tracking
Returns
T & Constructor<{ [WEBDA_DIRTY]: DirtyState; dirty: DirtyState; }>
A new class that wraps instances in a tracking proxy
Example
class User { name = ""; }
const TrackedUser = DirtyMixIn(User);
const u = new TrackedUser();
u.name = "Alice";
u.dirty; // DirtyState with "name"