Reputation: 101
import { writable } from 'svelte/store';
const createStore = () => {
const { update, subscribe } = writable({
url: 'hello',
amount: 42,
tip: 12,
payment: false,
});
return {
subscribe,
update,
clicker: () => {
count.payment.update((count.payment = true));
},
};
};
export const count = createStore();
Upvotes: 0
Views: 2304
Reputation: 16451
two problems:
count
is not defined that clicker functionupdate
worksupdate
takes as argument a function that has as argument the current value and as return value the new value: store.update(oldValue => newValue)
With those two things in mind, the correct code would be:
return {
clicker: () => update(current => {
current.payment = true;
return current;
})
}
Upvotes: 3