east Function – $patch

const $patch: <T>(
  $patch: (t: T) => Update<T>,
) => { $patch: (t: T) => Update<T> }

Apply a function that returns another patch to apply.

import { $patch, $apply, $delete } from "@use-gpu/state";

const value = {
  hello: {text: 'world', bar: 2, other: 1},
  foo: 1,
};

const update = {
  hello: $patch(({other}) => ({
    text: $apply(text => other + ' !!!'),
    bar: $delete(),
  })),
};

expect(patch(value, update)).toEqual({
  hello: {text: '1 !!!', other: 1},
  foo: 1,
});

Source

packages / state / src / patch.ts

Sections
Source  
menu
format_list_numbered