(
selector: (snapshot: SnapshotFrom<TLogic>) => TSelected,
equalityFn: (a: TSelected, b: TSelected) => boolean = Object.is
)
| 488 | } |
| 489 | |
| 490 | public select<TSelected>( |
| 491 | selector: (snapshot: SnapshotFrom<TLogic>) => TSelected, |
| 492 | equalityFn: (a: TSelected, b: TSelected) => boolean = Object.is |
| 493 | ): Readable<TSelected> { |
| 494 | return { |
| 495 | subscribe: (observerOrFn) => { |
| 496 | const observer = toObserver(observerOrFn); |
| 497 | const snapshot = this.getSnapshot(); |
| 498 | let previousSelected = selector(snapshot); |
| 499 | |
| 500 | return this.subscribe((snapshot) => { |
| 501 | const nextSelected = selector(snapshot); |
| 502 | if (!equalityFn(previousSelected, nextSelected)) { |
| 503 | previousSelected = nextSelected; |
| 504 | observer.next?.(nextSelected); |
| 505 | } |
| 506 | }); |
| 507 | }, |
| 508 | get: () => selector(this.getSnapshot()) |
| 509 | }; |
| 510 | } |
| 511 | |
| 512 | /** Starts the Actor from the initial state */ |
| 513 | public start(): this { |
nothing calls this directly
no test coverage detected