@figliolia/galena 2.2.8 → 2.3.0
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/README.md +4 -0
- package/dist/cjs/Galena/State.js +8 -0
- package/dist/mjs/Galena/State.js +8 -0
- package/dist/types/Galena/State.d.ts +6 -0
- package/package.json +1 -1
- package/src/Galena/State.ts +9 -0
package/README.md
CHANGED
|
@@ -346,6 +346,8 @@ import { Galena, Logger } from "@figliolia/galena";
|
|
|
346
346
|
const AppState = new Galena([new Logger()]);
|
|
347
347
|
```
|
|
348
348
|
|
|
349
|
+

|
|
350
|
+
|
|
349
351
|
#### Profiling Middleware
|
|
350
352
|
Galena also comes with a Profiler that can track the duration of all state transitions. When a state transition exceeds 16ms, a warning is printed to the console notifying the developer of a potential bottleneck in his or her application. By default the Profiler will log each time a state transition exceeds one full frame (16ms). This threshold can be adjusted by calling `new Profiler(/* any number of milliseconds */)`
|
|
351
353
|
|
|
@@ -355,6 +357,8 @@ import { Galena, Profiler } from "@figliolia/galena";
|
|
|
355
357
|
const AppState = new Galena([new Profiler()]);
|
|
356
358
|
```
|
|
357
359
|
|
|
360
|
+

|
|
361
|
+
|
|
358
362
|
### Middleware - Advanced Usage
|
|
359
363
|
Similar to a lot of stateful tools, `Galena` also exposes an API for creating your own Middleware. With it, you can do a lot of cool things for both development and productions environments. Let's first look at how to use middleware in `Galena`, then we'll walk through creating our own!
|
|
360
364
|
|
package/dist/cjs/Galena/State.js
CHANGED
|
@@ -246,6 +246,14 @@ class State extends Scheduler_1.Scheduler {
|
|
|
246
246
|
unsubscribe(ID) {
|
|
247
247
|
return this.emitter.off(this.name, ID);
|
|
248
248
|
}
|
|
249
|
+
/**
|
|
250
|
+
* Clear All Subscriptions
|
|
251
|
+
*
|
|
252
|
+
* Removes all open subscriptions to the `State` instance
|
|
253
|
+
*/
|
|
254
|
+
clearAllSubscriptions() {
|
|
255
|
+
return this.emitter.clear();
|
|
256
|
+
}
|
|
249
257
|
/**
|
|
250
258
|
* Life Cycle Event
|
|
251
259
|
*
|
package/dist/mjs/Galena/State.js
CHANGED
|
@@ -246,6 +246,14 @@ export class State extends Scheduler {
|
|
|
246
246
|
unsubscribe(ID) {
|
|
247
247
|
return this.emitter.off(this.name, ID);
|
|
248
248
|
}
|
|
249
|
+
/**
|
|
250
|
+
* Clear All Subscriptions
|
|
251
|
+
*
|
|
252
|
+
* Removes all open subscriptions to the `State` instance
|
|
253
|
+
*/
|
|
254
|
+
clearAllSubscriptions() {
|
|
255
|
+
return this.emitter.clear();
|
|
256
|
+
}
|
|
249
257
|
/**
|
|
250
258
|
* Life Cycle Event
|
|
251
259
|
*
|
|
@@ -209,6 +209,12 @@ export declare class State<T extends any = any> extends Scheduler {
|
|
|
209
209
|
* from the `State` instance
|
|
210
210
|
*/
|
|
211
211
|
unsubscribe(ID: string): boolean | undefined;
|
|
212
|
+
/**
|
|
213
|
+
* Clear All Subscriptions
|
|
214
|
+
*
|
|
215
|
+
* Removes all open subscriptions to the `State` instance
|
|
216
|
+
*/
|
|
217
|
+
clearAllSubscriptions(): void;
|
|
212
218
|
/**
|
|
213
219
|
* Life Cycle Event
|
|
214
220
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@figliolia/galena",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "A performant state management library supporting mutable state, batched updates, middleware and a rich development API",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/mjs/index.js",
|
package/src/Galena/State.ts
CHANGED
|
@@ -275,6 +275,15 @@ export class State<T extends any = any> extends Scheduler {
|
|
|
275
275
|
return this.emitter.off(this.name, ID);
|
|
276
276
|
}
|
|
277
277
|
|
|
278
|
+
/**
|
|
279
|
+
* Clear All Subscriptions
|
|
280
|
+
*
|
|
281
|
+
* Removes all open subscriptions to the `State` instance
|
|
282
|
+
*/
|
|
283
|
+
public clearAllSubscriptions() {
|
|
284
|
+
return this.emitter.clear();
|
|
285
|
+
}
|
|
286
|
+
|
|
278
287
|
/**
|
|
279
288
|
* Life Cycle Event
|
|
280
289
|
*
|