Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Patcher<T>

Class to track object changes and patch mechanism to support updating immutable/frozen objects.

Use applyPatch or applyAndReturnPatches for simple use-cases.

Type parameters

  • T: object

Hierarchy

  • Patcher

Index

Constructors

Properties

Methods

Constructors

constructor

  • Parameters

    • item: T

    Returns Patcher

Properties

item

item: T

patches

patches: Partial<T>

As soon as you change values in value, this patches object fills up.

Note: It does not resolve array operations. That means if you have a T shape of {items: string[]} and change value.items.push('another'), then patches contains {items: ['another]}.

Protected proxies

proxies: Map<any, any> = new Map<any, any>()

proxy

proxy: Mutable<T>

By updating certain values on this object, value property of this class will be changed accordingly, while only touching and de-referencing the property values that are absolutely necessary.

value

value: T

This is the object with the same shape and origin values as T and SHOULD NOT be changed. Use proxy when you want to apply changes.

Methods

Protected getArrayProxy

  • getArrayProxy(originalArray: any[], dereferenceArray: () => any[]): never[]
  • Parameters

    • originalArray: any[]
    • dereferenceArray: () => any[]
        • (): any[]
        • Returns any[]

    Returns never[]

Protected getProxy

  • getProxy(incomingPath: string, originalItem: any, dereferenceOriginalItem: () => object): any
  • Parameters

    • incomingPath: string
    • originalItem: any
    • dereferenceOriginalItem: () => object
        • (): object
        • Returns object

    Returns any

Generated using TypeDoc