createComputedCache
Public function
Free version of Store.createComputedCache.
Example
const myCache = createComputedCache(
'myCache',
(editor: Editor, shape: TLShape) => {
return editor.getSomethingExpensive(shape)
}
)
myCache.get(editor, shape.id)
Signature
function createComputedCache<
Context extends StoreContext<any>,
Result,
Record extends ContextRecordType<Context> = ContextRecordType<Context>,
>(
name: string,
derive: (context: Context, record: Record) => Result | undefined,
isEqual?: (a: Record, b: Record) => boolean
): {
get(context: Context, id: IdOf<Record>): Result | undefined
}
Parameters
Name | Description |
---|---|
|
|
|
|
|
|
Returns
{
get(context: Context, id: IdOf<Record>): Result | undefined
}
References
Source