Skip to content
This repository was archived by the owner on Sep 17, 2023. It is now read-only.

Commit 6fd85fd

Browse files
committed
Correct API docs
1 parent 0cd5dfc commit 6fd85fd

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

src/context-up-key.ts

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
ValueTracker,
1616
} from 'fun-events';
1717
import { ContextKey, ContextSeedKey, ContextValueOpts } from './context-key';
18+
import { ContextRef } from './context-ref';
1819
import { ContextSeeder } from './context-seeder';
1920
import { ContextValueProvider } from './context-value-spec';
2021
import { ContextValues } from './context-values';
@@ -117,13 +118,22 @@ export abstract class ContextUpKey<Value, Src> extends ContextKey<Value, Src | E
117118
* @param name Human-readable key name.
118119
* @param seedKey Value seed key. A new one will be constructed when omitted.
119120
*/
120-
protected constructor(name: string, seedKey?: ContextSeedKey<Src | EventKeeper<Src[]>, AfterEvent<Src[]>>) {
121+
constructor(name: string, seedKey?: ContextSeedKey<Src | EventKeeper<Src[]>, AfterEvent<Src[]>>) {
121122
super(name);
122123
this.seedKey = seedKey || new ContextSeedUpKey(this);
123124
}
124125

125126
}
126127

128+
/**
129+
* Single updatable context value reference.
130+
*
131+
* @typeparam Value Context value type.
132+
* @typeparam Seed Value seed type.
133+
*/
134+
export type SingleContextUpRef<Value, Seed = unknown> =
135+
ContextRef<AfterEvent<[Value]>, Value | AfterEvent<Value[]>, Seed>;
136+
127137
/**
128138
* Single updatable context value key.
129139
*
@@ -135,7 +145,9 @@ export abstract class ContextUpKey<Value, Src> extends ContextKey<Value, Src | E
135145
*
136146
* @typeparam Value Context value type.
137147
*/
138-
export class SingleContextUpKey<Value> extends ContextUpKey<AfterEvent<[Value]>, Value> {
148+
export class SingleContextUpKey<Value>
149+
extends ContextUpKey<AfterEvent<[Value]>, Value>
150+
implements SingleContextUpRef<Value, AfterEvent<Value[]>> {
139151

140152
/**
141153
* A provider of context value used when there is no value associated with this key.
@@ -193,6 +205,15 @@ export class SingleContextUpKey<Value> extends ContextUpKey<AfterEvent<[Value]>,
193205

194206
}
195207

208+
/**
209+
* Single updatable context value reference.
210+
*
211+
* @typeparam Src Source value type.
212+
* @typeparam Seed Value seed type.
213+
*/
214+
export type MultiContextUpRef<Src, Seed = unknown> =
215+
ContextRef<AfterEvent<Src[]>, Src | AfterEvent<Src[]>, Seed>;
216+
196217
/**
197218
* Multiple updatable context values key.
198219
*
@@ -202,9 +223,11 @@ export class SingleContextUpKey<Value> extends ContextUpKey<AfterEvent<[Value]>,
202223
* It is an error to provide a `null` or `undefined` {@link ContextRequest.Opts.or fallback value} when requesting
203224
* an associated value. Use an `afterEventOf()` result as a fallback instead.
204225
*
205-
* @typeparam Value Context value type.
226+
* @typeparam Src Source value type.
206227
*/
207-
export class MultiContextUpKey<Src> extends ContextUpKey<AfterEvent<Src[]>, Src> {
228+
export class MultiContextUpKey<Src>
229+
extends ContextUpKey<AfterEvent<Src[]>, Src>
230+
implements MultiContextUpRef<Src, AfterEvent<Src[]>> {
208231

209232
/**
210233
* A provider of context value used when there is no value associated with this key.

src/simple-context-key.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export abstract class SimpleContextKey<Value, Src = Value> extends ContextKey<Va
7070
* @param name Human-readable key name.
7171
* @param seedKey Value seed key. A new one will be constructed when omitted.
7272
*/
73-
protected constructor(name: string, seedKey?: ContextSeedKey<Src, AIterable<Src>>) {
73+
constructor(name: string, seedKey?: ContextSeedKey<Src, AIterable<Src>>) {
7474
super(name);
7575
this.seedKey = seedKey || new SimpleSeedKey(this);
7676
}
@@ -143,6 +143,7 @@ export class SingleContextKey<Value>
143143
* Represents context value as read-only array of source values.
144144
*
145145
* @typeparam Src Value source type and context value item type.
146+
* @typeparam Seed Value seed type.
146147
*/
147148
export type MultiContextRef<Src, Seed = unknown> = ContextRef<readonly Src[], Src, Seed>;
148149

0 commit comments

Comments
 (0)