@figliolia/galena 2.2.7 → 2.2.9
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
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
|
|
|
@@ -29,7 +29,7 @@ class Profiler extends Middleware_1.Middleware {
|
|
|
29
29
|
const endTime = performance.now();
|
|
30
30
|
const diff = endTime - this.startTime;
|
|
31
31
|
if (diff > this.threshold) {
|
|
32
|
-
console.warn(`A slow state transition was detected on ${nextState.name}`, nextState);
|
|
32
|
+
console.warn(`A slow state transition was detected on ${nextState.name}`, nextState.getState());
|
|
33
33
|
console.warn(`The last transition took ${diff}ms`);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -27,7 +27,7 @@ export class Profiler extends Middleware {
|
|
|
27
27
|
const endTime = performance.now();
|
|
28
28
|
const diff = endTime - this.startTime;
|
|
29
29
|
if (diff > this.threshold) {
|
|
30
|
-
console.warn(`A slow state transition was detected on ${nextState.name}`, nextState);
|
|
30
|
+
console.warn(`A slow state transition was detected on ${nextState.name}`, nextState.getState());
|
|
31
31
|
console.warn(`The last transition took ${diff}ms`);
|
|
32
32
|
}
|
|
33
33
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@figliolia/galena",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.9",
|
|
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",
|