Skip to content

Commit 771f5f2

Browse files
committed
wip
1 parent a44ef8c commit 771f5f2

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

packages/signals/signals-runtime/src/runtime-helpers.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BaseSignal, SignalOfType } from './types/shared'
1+
import { BaseSignal, SignalOfType, ISignalsRuntime } from './types/shared'
22

33
/**
44
* SignalsRuntime class to manage signals
@@ -13,7 +13,9 @@ import { BaseSignal, SignalOfType } from './types/shared'
1313
* type: 'foo'
1414
* })
1515
*/
16-
export class SignalsRuntime<Signal extends BaseSignal = BaseSignal> {
16+
export class SignalsRuntime<Signal extends BaseSignal = BaseSignal>
17+
implements ISignalsRuntime<Signal>
18+
{
1719
private signalBuffer: Signal[]
1820
// mobile only - see brandon for this code
1921
private signalCounter: number

packages/signals/signals-runtime/src/types/shared.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,11 @@ export type SignalOfType<
66
AllSignals extends BaseSignal,
77
SignalType extends AllSignals['type']
88
> = AllSignals & { type: SignalType }
9+
10+
export interface ISignalsRuntime<Signal extends BaseSignal> {
11+
find: <SignalType extends Signal['type']>(
12+
fromSignal: Signal,
13+
signalType: SignalType,
14+
predicate?: (signal: SignalOfType<Signal, SignalType>) => boolean
15+
) => SignalOfType<Signal, SignalType> | undefined
16+
}

packages/signals/signals-runtime/src/types/web/signals.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import type { BaseSignal, SignalOfType } from '../shared'
2-
31
export type JSONPrimitive = string | number | boolean | null
42
export type JSONValue = JSONPrimitive | JSONObject | JSONArray
53
export type JSONObject = { [member: string]: JSONValue }
@@ -110,11 +108,3 @@ export interface SegmentEvent {
110108
type: string // e.g 'track'
111109
[key: string]: any
112110
}
113-
114-
export interface ISignalsRuntime<Signal extends BaseSignal> {
115-
find: <SignalType extends Signal['type']>(
116-
fromSignal: Signal,
117-
signalType: SignalType,
118-
predicate?: (signal: SignalOfType<Signal, SignalType>) => boolean
119-
) => SignalOfType<Signal, SignalType> | undefined
120-
}

packages/signals/signals-runtime/src/web-exports-globals.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// all import directives will be removed in the final build
2-
import { ISignalsRuntime, Signal } from './web-exports'
2+
import { ISignalsRuntime } from './types/shared'
3+
import { Signal } from './web-exports'
34

45
// This will be appended to the generated code - dts-bundle-generator will not write declare const for whatever reason.
56
declare const signals: ISignalsRuntime<Signal>

0 commit comments

Comments
 (0)