setKeys method on store
Author: shiftlabs1Created May 25, 2022Updated Nov 10, 2023
First off, Thank you guys for this library. I wanted to ask if you can possibly include a setKeys (on the map store) method that internally simply does
const setKeys = (partialState : Partial<state>)=>{
store.set({...store.get(),...obj});
}or in the map store define this function
store.setKeys=function(object){
Object.keys(object).forEach(key=>{
store.setKey(key,object[key]);
})
}or a function that also handles deeply nested objects (like lodash-es merge method). I can't say how performant or not the second option is, but it leverages the checks done in setKey method. Or if there is a way to create an extension on the store that adds this, kindly point that to me. This will help reduce overall the lines of code one has to write as more often that not, we are partially updating the store , and setKey only does a key at a time.
Source: nanostores/nanostores