@dualjack/svelte-tools
Version:
### Why? Because runes are not safe to toss around by design.
45 lines (31 loc) • 843 B
Markdown
# Simple wrapper Svelte tools
### Why? Because runes are not safe to toss around by design.
I am not a fan of some patterns in svelte, so I buckled up
and created a set of utility tools for svelte users.
It's highly based on some Vue3 Composition API methods.
Everything is up-to-date with the newest svelte 5 runes.
No support for svelte 4.
## watch
```ts
watch(() => something, (newValue, oldValue) => {
}, {
lazy: true, // Do not run on mount.
pre: true // Before DOM changes
});
```
## ref
```ts
const something = ref('123');
something.current = '1234';
```
## computed
```ts
const something = computed(() => {
return '123'
});
```
## fromStoreToWayBinding
```ts
const something = fromStoreToWayBinding(existingStore);
something.current = '123'; // Changes will be applied both in store and in rune.
```