ecspresso 0.12.2 → 0.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ecspresso.d.ts +21 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/resource-manager.d.ts +16 -0
- package/package.json +1 -1
|
@@ -40,6 +40,7 @@ export default class ResourceManager<ResourceTypes extends Record<string, any> =
|
|
|
40
40
|
private resourceDependencies;
|
|
41
41
|
private resourceDisposers;
|
|
42
42
|
private initializedResourceKeys;
|
|
43
|
+
private _changeSubscribers;
|
|
43
44
|
/**
|
|
44
45
|
* Add a resource to the manager.
|
|
45
46
|
*
|
|
@@ -129,6 +130,21 @@ export default class ResourceManager<ResourceTypes extends Record<string, any> =
|
|
|
129
130
|
* @returns True if the resource existed and was disposed, false if it didn't exist
|
|
130
131
|
*/
|
|
131
132
|
disposeResource<K extends keyof ResourceTypes>(label: K, ...args: ContextArgs<Context>): Promise<boolean>;
|
|
133
|
+
/**
|
|
134
|
+
* Subscribe to changes for a specific resource key.
|
|
135
|
+
* @param key The resource key to watch
|
|
136
|
+
* @param callback Function called with (newValue, oldValue) when the resource changes
|
|
137
|
+
* @returns Unsubscribe function
|
|
138
|
+
*/
|
|
139
|
+
onResourceChange<K extends keyof ResourceTypes>(key: K, callback: (newValue: ResourceTypes[K], oldValue: ResourceTypes[K]) => void): () => void;
|
|
140
|
+
/**
|
|
141
|
+
* Notify subscribers of a resource value change.
|
|
142
|
+
* Skips notification if the value is unchanged (via Object.is).
|
|
143
|
+
* @param key The resource key that changed
|
|
144
|
+
* @param newValue The new resource value
|
|
145
|
+
* @param oldValue The previous resource value
|
|
146
|
+
*/
|
|
147
|
+
notifyChange<K extends keyof ResourceTypes>(key: K, newValue: ResourceTypes[K], oldValue: ResourceTypes[K]): void;
|
|
132
148
|
/**
|
|
133
149
|
* Dispose all initialized resources in reverse dependency order.
|
|
134
150
|
* Resources that depend on others are disposed first.
|