Svelte Store 中的 set() 和 update() 方法有什么区别?

What is the difference between set() and update() method in Svelte Store?

我是 Svelte 商店的新用户。 Here in svelte tutorial,他们在<Incrementer/><Decrementer/>组件中使用了update()方法来更新值。但是在<Resetter/>中,他们使用了set()方法来重置值。 update()set() 方法在 svelte store 中到底有什么区别?

来自docs

set is a method that takes one argument which is the value to be set. The store value gets set to the value of the argument if the store value is not already equal to it.

update is a method that takes one argument which is a callback. The callback takes the existing store value as its argument and returns the new value to be set to the store.

所以如果下一个值应该依赖于当前值,你可以使用更新。