Skip to content

Commit 0bb4dad

Browse files
committed
formate code
1 parent d1a566f commit 0bb4dad

2 files changed

Lines changed: 47 additions & 47 deletions

File tree

packages/solid/src/reactive/signal.ts

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -158,17 +158,17 @@ export function createRoot<T>(fn: RootFunction<T>, detachedOwner?: typeof Owner)
158158
? { owned: null, cleanups: null, context: null, owner: null }
159159
: UNOWNED
160160
: {
161-
owned: null,
162-
cleanups: null,
163-
context: current ? current.context : null,
164-
owner: current
165-
},
161+
owned: null,
162+
cleanups: null,
163+
context: current ? current.context : null,
164+
owner: current
165+
},
166166
updateFn = unowned
167167
? IS_DEV
168168
? () =>
169-
fn(() => {
170-
throw new Error("Dispose method must be an explicit argument to createRoot function");
171-
})
169+
fn(() => {
170+
throw new Error("Dispose method must be an explicit argument to createRoot function");
171+
})
172172
: fn
173173
: () => fn(() => untrack(() => cleanNode(root)));
174174

@@ -274,7 +274,7 @@ export interface BaseOptions {
274274
// TypeScript Discord conversation: https://discord.com/channels/508357248330760243/508357248330760249/911266491024949328
275275
export type NoInfer<T extends any> = [T][T extends any ? 0 : never];
276276

277-
export interface EffectOptions extends BaseOptions { }
277+
export interface EffectOptions extends BaseOptions {}
278278

279279
// Also similar to OnEffectFunction
280280
export type EffectFunction<Prev, Next extends Prev = Prev> = (v: Prev) => Next;
@@ -391,15 +391,15 @@ export function createEffect<Next, Init>(
391391
export function createReaction(onInvalidate: () => void, options?: EffectOptions) {
392392
let fn: (() => void) | undefined;
393393
const c = createComputation(
394-
() => {
395-
fn ? fn() : untrack(onInvalidate);
396-
fn = undefined;
397-
},
398-
undefined,
399-
false,
400-
0,
401-
IS_DEV ? options : undefined
402-
),
394+
() => {
395+
fn ? fn() : untrack(onInvalidate);
396+
fn = undefined;
397+
},
398+
undefined,
399+
false,
400+
0,
401+
IS_DEV ? options : undefined
402+
),
403403
s = SuspenseContext && useContext(SuspenseContext);
404404
if (s) c.suspense = s;
405405
c.user = true;
@@ -705,15 +705,15 @@ export function createResource<T, S, R>(
705705
initP !== NO_INIT
706706
? (initP as T | Promise<T>)
707707
: untrack(() => {
708-
try {
709-
return fetcher(lookup, {
710-
value: value(),
711-
refetching
712-
});
713-
} catch (fetcherError) {
714-
error = fetcherError;
715-
}
716-
});
708+
try {
709+
return fetcher(lookup, {
710+
value: value(),
711+
refetching
712+
});
713+
} catch (fetcherError) {
714+
error = fetcherError;
715+
}
716+
});
717717
if (error !== undefined) {
718718
loadEnd(pr, undefined, castError(error), lookup);
719719
return;
@@ -914,8 +914,8 @@ export function untrack<T>(fn: Accessor<T>): T {
914914
export type ReturnTypes<T> = T extends readonly Accessor<unknown>[]
915915
? { [K in keyof T]: T[K] extends Accessor<infer I> ? I : never }
916916
: T extends Accessor<infer I>
917-
? I
918-
: never;
917+
? I
918+
: never;
919919

920920
// transforms a tuple to a tuple of accessors in a way that allows generics to be inferred
921921
export type AccessorArray<T> = [...Extract<{ [K in keyof T]: Accessor<T[K]> }, readonly unknown[]>];
@@ -1778,10 +1778,10 @@ function createProvider(id: symbol, options?: EffectOptions) {
17781778
let res;
17791779
createRenderEffect(
17801780
() =>
1781-
(res = untrack(() => {
1782-
Owner!.context = { ...Owner!.context, [id]: props.value };
1783-
return children(() => props.children);
1784-
})),
1781+
(res = untrack(() => {
1782+
Owner!.context = { ...Owner!.context, [id]: props.value };
1783+
return children(() => props.children);
1784+
})),
17851785
undefined,
17861786
options
17871787
);

packages/solid/test/signals.spec.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -606,23 +606,23 @@ describe("catchError", () => {
606606
});
607607

608608
describe("Repeatedly read the signal", () => {
609-
test("Signal repeated read in for loop", () => {
610-
const a = createSignal(0);
611-
const dispose = createRoot(dispose => {
612-
createEffect(() => {
613-
for (let i = 0; i < 1000; i++) {
614-
a[0]();
615-
}
609+
test("Signal repeated read in for loop", () => {
610+
const a = createSignal(0);
611+
const dispose = createRoot(dispose => {
612+
createEffect(() => {
613+
for (let i = 0; i < 1000; i++) {
614+
a[0]();
615+
}
616+
});
617+
return dispose;
616618
});
617-
return dispose;
619+
expect((a as any).state.observers.length).toBe(1);
620+
expect((a as any).state.observerSlots.length).toBe(1);
621+
expect((a as any).state.observers[0].sources.length).toBe(1);
622+
expect((a as any).state.observers[0].sourceSlots.length).toBe(1);
623+
dispose();
618624
});
619-
expect((a as any).state.observers.length).toBe(1);
620-
expect((a as any).state.observerSlots.length).toBe(1);
621-
expect((a as any).state.observers[0].sources.length).toBe(1);
622-
expect((a as any).state.observers[0].sourceSlots.length).toBe(1);
623-
dispose();
624625
});
625-
});
626626

627627
test("In nested memo", () => {
628628
let errored = false;

0 commit comments

Comments
 (0)