createComputedCache
See source codeFree version of Store.createComputedCache.
function createComputedCache<
  Context extends StoreObject<any>,
  Result,
  Record extends
    StoreObjectRecordType<Context> = StoreObjectRecordType<Context>,
>(
  name: string,
  derive: (context: Context, record: Record) => Result | undefined,
  opts?: CreateComputedCacheOpts<Result, Record>
): {
  get(context: Context, id: IdOf<Record>): Result | undefined
}Example
const myCache = createComputedCache(
  'myCache',
  (editor: Editor, shape: TLShape) => {
    return editor.getSomethingExpensive(shape)
  }
)
myCache.get(editor, shape.id)Parameters
| Name | Description | 
|---|---|
| 
 |  | 
| 
 |  | 
| 
 |  | 
Returns
{
  get(context: Context, id: IdOf<Record>): Result | undefined
}Prev
assertIdTypeNext
createMigrationIds