34 lines
700 B
Svelte
34 lines
700 B
Svelte
|
<script lang="ts">
|
||
|
import {store, increment, decrement, useSvelteSelector} from 'store/store';
|
||
|
|
||
|
$: counter = useSvelteSelector((state)=> state.counter.value, newCounter => (counter = newCounter));
|
||
|
|
||
|
function incrementCount() {
|
||
|
store.dispatch(increment())
|
||
|
|
||
|
}
|
||
|
|
||
|
function decrementCount() {
|
||
|
store.dispatch(decrement())
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<style>
|
||
|
.container{
|
||
|
display: flex;
|
||
|
font-size: 3rem;
|
||
|
margin: auto;
|
||
|
max-width: 800px;
|
||
|
margin-top: 20px;
|
||
|
font-family: Arial, Helvetica, sans-serif;
|
||
|
}
|
||
|
|
||
|
|
||
|
</style>
|
||
|
|
||
|
<div class="container">
|
||
|
<div> Svelt Counter:{counter}</div>
|
||
|
<button on:click={incrementCount}>+</button>
|
||
|
<button on:click={decrementCount}>-</button>
|
||
|
</div>
|