@@ -15,6 +15,7 @@ import {
15
15
ValueTracker ,
16
16
} from 'fun-events' ;
17
17
import { ContextKey , ContextSeedKey , ContextValueOpts } from './context-key' ;
18
+ import { ContextRef } from './context-ref' ;
18
19
import { ContextSeeder } from './context-seeder' ;
19
20
import { ContextValueProvider } from './context-value-spec' ;
20
21
import { ContextValues } from './context-values' ;
@@ -117,13 +118,22 @@ export abstract class ContextUpKey<Value, Src> extends ContextKey<Value, Src | E
117
118
* @param name Human-readable key name.
118
119
* @param seedKey Value seed key. A new one will be constructed when omitted.
119
120
*/
120
- protected constructor ( name : string , seedKey ?: ContextSeedKey < Src | EventKeeper < Src [ ] > , AfterEvent < Src [ ] > > ) {
121
+ constructor ( name : string , seedKey ?: ContextSeedKey < Src | EventKeeper < Src [ ] > , AfterEvent < Src [ ] > > ) {
121
122
super ( name ) ;
122
123
this . seedKey = seedKey || new ContextSeedUpKey ( this ) ;
123
124
}
124
125
125
126
}
126
127
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
+
127
137
/**
128
138
* Single updatable context value key.
129
139
*
@@ -135,7 +145,9 @@ export abstract class ContextUpKey<Value, Src> extends ContextKey<Value, Src | E
135
145
*
136
146
* @typeparam Value Context value type.
137
147
*/
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 [ ] > > {
139
151
140
152
/**
141
153
* 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]>,
193
205
194
206
}
195
207
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
+
196
217
/**
197
218
* Multiple updatable context values key.
198
219
*
@@ -202,9 +223,11 @@ export class SingleContextUpKey<Value> extends ContextUpKey<AfterEvent<[Value]>,
202
223
* It is an error to provide a `null` or `undefined` {@link ContextRequest.Opts.or fallback value} when requesting
203
224
* an associated value. Use an `afterEventOf()` result as a fallback instead.
204
225
*
205
- * @typeparam Value Context value type.
226
+ * @typeparam Src Source value type.
206
227
*/
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 [ ] > > {
208
231
209
232
/**
210
233
* A provider of context value used when there is no value associated with this key.
0 commit comments