Skip to content

Commit a06a4e6

Browse files
committed
revert some unnecessary changes, to reduce diff size
1 parent defb351 commit a06a4e6

File tree

6 files changed

+37
-34
lines changed

6 files changed

+37
-34
lines changed

packages/svelte/src/internal/client/runtime.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { subscribe_to_store } from '../../store/index.js';
21
import { DEV } from 'esm-env';
2+
import { subscribe_to_store } from '../../store/utils.js';
33
import { noop, run_all } from '../common.js';
44
import {
55
array_prototype,

packages/svelte/src/internal/server/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as $ from '../client/runtime.js';
22
import { set_is_ssr } from '../client/runtime.js';
33
import { is_promise, noop } from '../common.js';
4-
import { subscribe_to_store } from '../../store/index.js';
4+
import { subscribe_to_store } from '../../store/utils.js';
55
import { DOMBooleanAttributes } from '../../constants.js';
66

77
export * from '../client/validate.js';

packages/svelte/src/motion/spring.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ function tick_spring(ctx, last_value, current_value, target_value) {
4848
}
4949

5050
/**
51-
* The spring function in Svelte creates a store whose value is animated, with a motion that
52-
* simulates the behavior of a spring. This means when the value changes, instead of transitioning
53-
* at a steady rate, it "bounces" like a spring would, depending on the physics parameters provided.
54-
* This adds a level of realism to the transitions and can enhance the user experience.
51+
* The spring function in Svelte creates a store whose value is animated, with a motion that simulates the behavior of a spring. This means when the value changes, instead of transitioning at a steady rate, it "bounces" like a spring would, depending on the physics parameters provided. This adds a level of realism to the transitions and can enhance the user experience.
5552
*
5653
* https://svelte.dev/docs/svelte-motion#spring
5754
* @template [T=any]

packages/svelte/src/motion/tweened.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ function get_interpolator(a, b) {
7171
}
7272

7373
/**
74-
* A tweened store in Svelte is a special type of store that provides smooth transitions between
75-
* state values over time.
74+
* A tweened store in Svelte is a special type of store that provides smooth transitions between state values over time.
7675
*
7776
* https://svelte.dev/docs/svelte-motion#tweened
7877
* @template T
@@ -125,9 +124,9 @@ export function tweened(value, defaults = {}) {
125124
if (now < start) return true;
126125
if (!started) {
127126
fn = interpolate(/** @type {any} */ (value), new_value);
128-
if (typeof duration === 'function') {
127+
if (typeof duration === 'function')
129128
duration = duration(/** @type {any} */ (value), new_value);
130-
}
129+
131130
started = true;
132131
}
133132
if (previous_task) {

packages/svelte/src/store/index.js

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -501,27 +501,3 @@ export function get_store_value(store, allow_stale = false) {
501501
}
502502

503503
export { get_store_value as get };
504-
505-
/**
506-
* @template T
507-
* @param {import('./public.js').Readable<T> | import('./public.js').ExternalReadable<T> | null | undefined} store
508-
* @param {(value: T) => void} run
509-
* @param {(value: T) => void} [invalidate]
510-
* @returns {() => void}
511-
*/
512-
export function subscribe_to_store(store, run, invalidate) {
513-
if (store == null) {
514-
// @ts-expect-error
515-
run(undefined);
516-
517-
// @ts-expect-error
518-
if (invalidate) invalidate(undefined);
519-
520-
return noop;
521-
}
522-
523-
// @ts-expect-error `SubscriberInvalidator<T>` is not public.
524-
const unsubscribe = store.subscribe([run, invalidate]);
525-
const is_rxjs = typeof unsubscribe !== 'function';
526-
return is_rxjs ? unsubscribe.unsubscribe : unsubscribe;
527-
}

packages/svelte/src/store/utils.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { noop } from '../internal/common.js';
2+
3+
/**
4+
* @template T
5+
* @param {import('./public').Readable<T> | null | undefined} store
6+
* @param {(value: T) => void} run
7+
* @param {(value: T) => void} [invalidate]
8+
* @returns {() => void}
9+
*/
10+
export function subscribe_to_store(store, run, invalidate) {
11+
if (store == null) {
12+
// @ts-expect-error
13+
run(undefined);
14+
15+
// @ts-expect-error
16+
if (invalidate) invalidate(undefined);
17+
18+
return noop;
19+
}
20+
21+
// Svelte store takes a private second argument
22+
const unsub = store.subscribe(
23+
run,
24+
// @ts-expect-error
25+
invalidate
26+
);
27+
28+
// Also support RxJS
29+
// @ts-expect-error TODO fix this in the types?
30+
return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
31+
}

0 commit comments

Comments
 (0)