# Class ChangeRecorder

Records changes to a object which can later be reversed.

##### Index

### Constructors

constructor

### Methods

onRestore
restoreAll
save
set

## Constructors

### constructor

- new ChangeRecorder(): ChangeRecorder

  #### Returns ChangeRecorder

## Methods

### onRestore

- onRestore<O extends unknown>(o: O, onRestore: (obj: O) => void): void

  Register callback, for `o`, which will be invoked when restoreAll is called. Useful when a more complex state needs to be restored when restoreAll is called. The callback is then responsible for modifying `o` when restoreAll is called.

  #### Type Parameters

  - O extends unknown

  #### Parameters

  - o: O

    Object to register callback for.

  - onRestore: (obj: O) => void

    callback.

  #### Returns void

### restoreAll

- restoreAll(): void

  Reverts all changes made to the objects.

  #### Returns void

### save

- save<O extends unknown, P extends string | number | symbol>(
  obj: O,
  prop: P,
  ): void

  Save a property `prop` on `obj`. This value will be restored when restoreAll is called later.

  #### Type Parameters

  - O extends unknown
  - P extends string | number | symbol

  #### Parameters

  - obj: O
  - prop: P

  #### Returns void

### set

- set<O extends unknown, P extends string | number | symbol, V>(
  obj: O,
  prop: P,
  newValue: V,
  ): void

  Set a property `prop` on `obj` to `newValue`. This can later be reversed by calling restoreAll.

  #### Type Parameters

  - O extends unknown
  - P extends string | number | symbol
  - V

  #### Parameters

  - obj: O

    Object to set property on.

  - prop: P

    Property to set

  - newValue: V

    New value which `obj[prop]` will get.

  #### Returns void