Reimplement cache more lol
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
import { type User } from "common/the_api";
|
||||
import { Update } from "common";
|
||||
import { User } from "common/the_api";
|
||||
import { identity } from "effect";
|
||||
import { useLayoutEffect, useState } from "react";
|
||||
|
||||
export type Update<T> = T | ((prev: T) => T);
|
||||
export type Updater<T> = (action: Update<T>) => void;
|
||||
|
||||
export const mapProp = <const K extends string, T>(prop: K, action: Update<T>) => <O extends { readonly [_ in K]: T }>(object: O): O => {
|
||||
return Object.freeze({ ...object, [prop]: typeof action === "function" ? (action as (prev: T) => T)(object[prop]) : action });
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user