-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add svelte/reactivity/window
module
#14660
Conversation
🦋 Changeset detectedLatest commit: 40c33e9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
preview: https://svelte-dev-git-preview-svelte-14660-svelte.vercel.app/ this is an automated message |
|
What about I also wonder about events, specifically not needing to have them for things like <script>
import { onWindow } from 'svelte/reactivity/window';
onWindow('online', () => {
})
</script> Then it reduces to need to use |
Hid some internal types and added |
There's no event that fires when it changes, so we'd need to monkey-patch I like the idea of event listeners in theory but I'm not sure what a good API looks like, so I don't think we should add it to this PR.
Yeah, I thought about that, but to be honest I'm not sure it's a good idea. The scenarios in which you should be programmatically manipulating scroll are very few and far between, and |
Yeah fine with me - especially now that you can pass functions to bindings, so you're not forcibly reduced to member expressions anymore in that situation (man, this feature is really paying dividends) |
For |
|
These are preferable to the existing
<svelte:window>
bindings insofar as they can be used in more places, and with less boilerplate. Before:After:
Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.packages/svelte/src
, add a changeset (npx changeset
).Tests and linting
pnpm test
and lint the project withpnpm lint