synapse-storage
Version:
Набор инструментов для управления состоянием и апи-запросами
15 lines (14 loc) • 696 B
TypeScript
/**
* Creates a dummy Proxy state object for path extraction.
*/
export declare function createDummyState<T>(): T;
/**
* Extracts the property path from a selector function using Proxy.
*
* **Limitations:**
* - Does not support conditional logic (if/ternary): Proxy records ALL accessed paths
* and returns the longest, which leads to subscription on the wrong path.
* - Does not support destructuring or array methods (map, filter, etc.)
* - For such cases use string-based subscription: `storage.subscribe('user.permissions', callback)`
*/
export declare function extractPath<T>(selector: (state: T) => any, dummyState: T, cache?: WeakMap<(...args: any[]) => any, string>): string;