Svelte integration for the Anchor reactive state management library.
npm install @anchorlib/svelte
For full documentation, visit Anchor for Svelte
<script>
import { anchorRef } from '@anchorlib/svelte';
// Create a reactive state object
const state = anchorRef({
count: 0,
user: {
name: 'John Doe',
email: 'john@example.com'
}
});
</script>
<div>
<h1>Hello {$state.user.name}</h1>
<p>Count: {$state.count}</p>
<button onclick={() => $state.count++}>Increment</button>
<button onclick={() => $state.user.name = 'Jane Doe'}>Change Name</button>
</div>
MIT