reducer.ts ×3

Frontier kind: Code frontier

unlabeled · c_a22d472f4822

42 tests · 6554 LOC · 60 files · introduces 0 tests · 49 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
3 ranges49 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
948 ranges6554 lines · 60 files · Browse complete extent
All tests (intent)
42 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 49 introduced LOC across 3 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/base/common/observableInternal/experimental/reducer.ts 49 introduced LOC · 3 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- reducer.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { EqualityComparer, strictEquals, BugIndicatingError } from '../commonFacade/deps.js';
7 > import { IObservable, IObservableWithChange, ISettableObservable } from '../base.js';
8 > import { subtransaction } from '../transaction.js';
9 > import { IChangeTracker } from '../changeTracker.js';
10 > import { DebugNameData, DebugOwner } from '../debugName.js';
11 > import { DerivedWithSetter, IDerivedReader } from '../observables/derivedImpl.js';
12 > import { DebugLocation } from '../debugLocation.js';
13 >
14 > export interface IReducerOptions<T, TChangeSummary = void, TOutChange = void> {
15 > /**
16 > * Is called to create the initial value of the observable when it becomes observed.
17 > */
18 > initial: T | (() => T);
19 >
20 > /**
21 > * Is called to dispose the observable value when it is no longer observed.
22 > */
23 > disposeFinal?(value: T): void;
24 > changeTracker?: IChangeTracker<TChangeSummary>;
25 > equalityComparer?: EqualityComparer<T>;
26 >
27 > /**
28 > * Applies the changes to the value.
29 > * Use `reader.reportChange` to report change details or to report a change if the same value is returned.
30 > */
31 > update(reader: IDerivedReader<TOutChange>, previousValue: T, changes: TChangeSummary): T;
32 > }
33 >
34 > /**
35 > * Creates an observable value that is based on values and changes from other observables.
36 > * Additionally, a reducer can report how that state changed.
37 > */
38 > export function observableReducer<T, TInChanges, TOutChange = void>(owner: DebugOwner, options: IReducerOptions<T, TInChanges, TOutChange>): SimplifyObservableWithChange<T, TOutChange> {
39 // eslint-disable-next-line local/code-no-any-casts
40 return observableReducerSettable<T, TInChanges, TOutChange>(owner, options) as any;
41 }
42 > reducer.ts
43 > /**
44 > * Creates an observable value that is based on values and changes from other observables.
45 > * Additionally, a reducer can report how that state changed.
46 > */
47 > export function observableReducerSettable<T, TInChanges, TOutChange = void>(owner: DebugOwner, options: IReducerOptions<T, TInChanges, TOutChange>): ISettableObservable<T, TOutChange> {
48 let prevValue: T | undefined = undefined;
49 let hasValue = false;
82 return d;
83 }
84 > reducer.ts
85 > /**
86 > * Returns IObservable<T> if TChange is void, otherwise IObservableWithChange<T, TChange>
87 > */
88 > type SimplifyObservableWithChange<T, TChange> = TChange extends void ? IObservable<T> : IObservableWithChange<T, TChange>;