Skip to content

Commit 54acbc0

Browse files
committed
chore: rename the Signal class to SignalImpl
1 parent 2944830 commit 54acbc0

File tree

7 files changed

+29
-29
lines changed

7 files changed

+29
-29
lines changed

packages/docs/src/routes/api/qwik/api.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@
730730
}
731731
],
732732
"kind": "Function",
733-
"content": "```typescript\nisSignal: (value: any) => value is ISignal<unknown>\n```\n\n\n<table><thead><tr><th>\n\nParameter\n\n\n</th><th>\n\nType\n\n\n</th><th>\n\nDescription\n\n\n</th></tr></thead>\n<tbody><tr><td>\n\nvalue\n\n\n</td><td>\n\nany\n\n\n</td><td>\n\n\n</td></tr>\n</tbody></table>\n**Returns:**\n\nvalue is [ISignal](#signal)<!-- -->&lt;unknown&gt;",
733+
"content": "```typescript\nisSignal: (value: any) => value is Signal<unknown>\n```\n\n\n<table><thead><tr><th>\n\nParameter\n\n\n</th><th>\n\nType\n\n\n</th><th>\n\nDescription\n\n\n</th></tr></thead>\n<tbody><tr><td>\n\nvalue\n\n\n</td><td>\n\nany\n\n\n</td><td>\n\n\n</td></tr>\n</tbody></table>\n**Returns:**\n\nvalue is [Signal](#signal)<!-- -->&lt;unknown&gt;",
734734
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/signal/signal.ts",
735735
"mdFile": "core.issignal.md"
736736
},

packages/docs/src/routes/api/qwik/index.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1424,7 +1424,7 @@ interface IntrinsicElements extends LenientQwikElements
14241424
## isSignal
14251425
14261426
```typescript
1427-
isSignal: (value: any) => value is ISignal<unknown>
1427+
isSignal: (value: any) => value is Signal<unknown>
14281428
```
14291429
14301430
<table><thead><tr><th>
@@ -1454,7 +1454,7 @@ any
14541454
</tbody></table>
14551455
**Returns:**
14561456
1457-
value is [ISignal](#signal)&lt;unknown&gt;
1457+
value is [Signal](#signal)&lt;unknown&gt;
14581458
14591459
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/signal/signal.ts)
14601460

packages/qwik/src/core/shared/shared-serialization.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
type EffectSubscription,
1515
EffectSubscriptionProp,
1616
SerializerSignalImpl,
17-
Signal,
17+
SignalImpl,
1818
SubscriptionData,
1919
WrappedSignal,
2020
isSerializerObj,
@@ -263,7 +263,7 @@ const inflate = (
263263
break;
264264
}
265265
case TypeIds.Signal: {
266-
const signal = target as Signal<unknown>;
266+
const signal = target as SignalImpl<unknown>;
267267
const d = data as [unknown, ...EffectSubscription[]];
268268
signal.$untrackedValue$ = d[0];
269269
signal.$effects$ = new Set(d.slice(1) as EffectSubscription[]);
@@ -488,7 +488,7 @@ const allocate = (container: DeserializeContainer, typeId: number, value: unknow
488488
case TypeIds.Component:
489489
return componentQrl(null!);
490490
case TypeIds.Signal:
491-
return new Signal(container as any, 0);
491+
return new SignalImpl(container as any, 0);
492492
case TypeIds.WrappedSignal:
493493
return new WrappedSignal(container as any, null!, null!, null!);
494494
case TypeIds.ComputedSignal:
@@ -836,7 +836,7 @@ export const createSerializationContext = (
836836
obj.forEach((v, k) => {
837837
discoveredValues.push(k, v);
838838
});
839-
} else if (obj instanceof Signal) {
839+
} else if (obj instanceof SignalImpl) {
840840
/**
841841
* ComputedSignal can be left un-calculated if invalid.
842842
*
@@ -1221,7 +1221,7 @@ function serialize(serializationContext: SerializationContext): void {
12211221
} else if ($isDomRef$(value)) {
12221222
value.$ssrNode$.vnodeData[0] |= VNodeDataFlag.SERIALIZE;
12231223
output(TypeIds.RefVNode, value.$ssrNode$.id);
1224-
} else if (value instanceof Signal) {
1224+
} else if (value instanceof SignalImpl) {
12251225
/**
12261226
* Special case: when a Signal value is an SSRNode, it always needs to be a DOM ref instead.
12271227
* It can never be meant to become a vNode, because vNodes are internal only.
@@ -1604,7 +1604,7 @@ const frameworkType = (obj: any) => {
16041604
return (
16051605
(typeof obj === 'object' &&
16061606
obj !== null &&
1607-
(obj instanceof Signal || obj instanceof Task || isJSXNode(obj))) ||
1607+
(obj instanceof SignalImpl || obj instanceof Task || isJSXNode(obj))) ||
16081608
isQrl(obj)
16091609
);
16101610
};

packages/qwik/src/core/shared/shared-serialization.unit.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { $, component$, noSerialize } from '@qwik.dev/core';
22
import { describe, expect, it, vi } from 'vitest';
33
import { _fnSignal, _wrapProp } from '../internal';
4-
import { SubscriptionData, type Signal } from '../signal/signal';
4+
import { SubscriptionData, type SignalImpl } from '../signal/signal';
55
import {
66
createComputed$,
77
createSerializer$,
@@ -581,8 +581,8 @@ describe('shared-serialization', () => {
581581
it(title(TypeIds.Promise), async () => {
582582
const objs = await serialize(Promise.resolve(shared1), Promise.reject(shared1), shared1);
583583
const [p1, p2, shared] = deserialize(objs);
584-
expect(p1).resolves.toBe(shared);
585-
expect(p2).rejects.toBe(shared);
584+
await expect(p1).resolves.toBe(shared);
585+
await expect(p2).rejects.toBe(shared);
586586
});
587587
it(title(TypeIds.Set), async () => {
588588
const objs = await serialize(shared1, new Set([shared1, ['hi']]));
@@ -658,7 +658,7 @@ describe('shared-serialization', () => {
658658
it.todo(title(TypeIds.Component));
659659
it(title(TypeIds.Signal), async () => {
660660
const objs = await serialize(createSignal('hi'));
661-
const signal = deserialize(objs)[0] as Signal;
661+
const signal = deserialize(objs)[0] as SignalImpl;
662662
expect(isSignal(signal)).toBeTruthy();
663663
expect(signal.value).toBe('hi');
664664
});

packages/qwik/src/core/signal/signal-api.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { QRL } from '../shared/qrl/qrl.public';
33
import {
44
ComputedSignalImpl,
55
SerializerSignalImpl,
6-
Signal as SignalImpl,
6+
SignalImpl,
77
throwIfQRLNotResolved,
88
type SerializerArg,
99
} from './signal';

packages/qwik/src/core/signal/signal-cleanup.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
EffectSubscriptionProp,
33
WrappedSignal,
44
type EffectSubscription,
5-
Signal,
5+
SignalImpl,
66
type EffectProperty,
77
type Consumer,
88
} from './signal';
@@ -30,7 +30,7 @@ export function clearAllEffects(container: Container, consumer: Consumer): void
3030
return;
3131
}
3232
for (const producer of backRefs) {
33-
if (producer instanceof Signal) {
33+
if (producer instanceof SignalImpl) {
3434
clearSignal(container, producer, effect);
3535
} else if (container.$storeProxyMap$.has(producer)) {
3636
const target = container.$storeProxyMap$.get(producer)!;
@@ -41,7 +41,7 @@ export function clearAllEffects(container: Container, consumer: Consumer): void
4141
}
4242
}
4343

44-
function clearSignal(container: Container, producer: Signal, effect: EffectSubscription) {
44+
function clearSignal(container: Container, producer: SignalImpl, effect: EffectSubscription) {
4545
const effects = producer.$effects$;
4646
if (effects) {
4747
effects.delete(effect);

packages/qwik/src/core/signal/signal.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import { trackSignal, tryGetInvokeContext } from '../use/use-core';
3232
import { Task, TaskFlags, isTask } from '../use/use-task';
3333
import { NEEDS_COMPUTATION, _EFFECT_BACK_REF } from './flags';
3434
import { type BackRef } from './signal-cleanup';
35-
import type { Signal as ISignal, ReadonlySignal } from './signal.public';
35+
import type { Signal, ReadonlySignal } from './signal.public';
3636
import type { TargetType } from './store';
3737
import { getSubscriber } from './subscriber';
3838

@@ -74,8 +74,8 @@ export const throwIfQRLNotResolved = (qrl: QRL) => {
7474
};
7575

7676
/** @public */
77-
export const isSignal = (value: any): value is ISignal<unknown> => {
78-
return value instanceof Signal;
77+
export const isSignal = (value: any): value is Signal<unknown> => {
78+
return value instanceof SignalImpl;
7979
};
8080

8181
/**
@@ -87,7 +87,7 @@ export const isSignal = (value: any): value is ISignal<unknown> => {
8787
* - `VNode` and `ISsrNode`: Either a component or `<Signal>`
8888
* - `Signal2`: A derived signal which contains a computation function.
8989
*/
90-
export type Consumer = Task | VNode | ISsrNode | Signal;
90+
export type Consumer = Task | VNode | ISsrNode | SignalImpl;
9191

9292
/** @internal */
9393
export class SubscriptionData {
@@ -137,7 +137,7 @@ export class SubscriptionData {
137137
export type EffectSubscription = [
138138
Consumer, // EffectSubscriptionProp.CONSUMER
139139
EffectProperty | string, // EffectSubscriptionProp.PROPERTY or string for attributes
140-
Set<Signal | TargetType> | null, // EffectSubscriptionProp.BACK_REF
140+
Set<SignalImpl | TargetType> | null, // EffectSubscriptionProp.BACK_REF
141141
SubscriptionData | null, // EffectSubscriptionProp.DATA
142142
];
143143

@@ -153,7 +153,7 @@ export const enum EffectProperty {
153153
VNODE = '.',
154154
}
155155

156-
export class Signal<T = any> implements ISignal<T> {
156+
export class SignalImpl<T = any> implements Signal<T> {
157157
$untrackedValue$: T;
158158

159159
/** Store a list of effects which are dependent on this signal. */
@@ -273,7 +273,7 @@ export const addQrlToSerializationCtx = (
273273

274274
export const triggerEffects = (
275275
container: Container | null,
276-
signal: Signal | TargetType,
276+
signal: SignalImpl | TargetType,
277277
effects: Set<EffectSubscription> | null
278278
) => {
279279
const isBrowser = isDomContainer(container);
@@ -290,7 +290,7 @@ export const triggerEffects = (
290290
choreType = ChoreType.VISIBLE;
291291
}
292292
container.$scheduler$(choreType, consumer);
293-
} else if (consumer instanceof Signal) {
293+
} else if (consumer instanceof SignalImpl) {
294294
// we don't schedule ComputedSignal/DerivedSignal directly, instead we invalidate it and
295295
// and schedule the signals effects (recursively)
296296
if (consumer instanceof ComputedSignalImpl) {
@@ -311,15 +311,15 @@ export const triggerEffects = (
311311
} else if (isBrowser) {
312312
if (property === EffectProperty.VNODE) {
313313
const host: HostElement = consumer;
314-
container.$scheduler$(ChoreType.NODE_DIFF, host, host, signal as Signal);
314+
container.$scheduler$(ChoreType.NODE_DIFF, host, host, signal as SignalImpl);
315315
} else {
316316
const host: HostElement = consumer;
317317
const effectData = effectSubscription[EffectSubscriptionProp.DATA];
318318
if (effectData instanceof SubscriptionData) {
319319
const data = effectData.data;
320320
const payload: NodePropPayload = {
321321
...data,
322-
$value$: signal as Signal,
322+
$value$: signal as SignalImpl,
323323
};
324324
container.$scheduler$(ChoreType.NODE_PROP, host, property, payload);
325325
}
@@ -341,7 +341,7 @@ type ComputeQRL<T> = QRLInternal<() => T>;
341341
*
342342
* The value is available synchronously, but the computation is done lazily.
343343
*/
344-
export class ComputedSignalImpl<T> extends Signal<T> implements BackRef {
344+
export class ComputedSignalImpl<T> extends SignalImpl<T> implements BackRef {
345345
/**
346346
* The compute function is stored here.
347347
*
@@ -435,7 +435,7 @@ export class ComputedSignalImpl<T> extends Signal<T> implements BackRef {
435435
}
436436
}
437437

438-
export class WrappedSignal<T> extends Signal<T> implements BackRef {
438+
export class WrappedSignal<T> extends SignalImpl<T> implements BackRef {
439439
$args$: any[];
440440
$func$: (...args: any[]) => T;
441441
$funcStr$: string | null;

0 commit comments

Comments
 (0)