square / svelte-store

529 stars 35 forks source link

feat: asyncWritable mappingWriteFunction passed previous value of store #4

Closed Akolyte01 closed 2 years ago

Akolyte01 commented 2 years ago

This will add a new argument that is passed to the mappingWriteFunction when .set or .update is called on an asyncWritable store. The old value of the store is passed to the store so that developers can make decisions based on it. Primarily this includes the ability to reset the store to its old value in case of a failed write by returning the old value from the mappingWriteFunction after a caught exception.