cefn / lauf

Monorepo for lauf packages.
MIT License
5 stars 0 forks source link

Remove patch from WIP 2.0.0 branch #208

Open cefn opened 1 year ago

cefn commented 1 year ago

Although the patch() signature looked promising to eliminate potentially unpleasant syntax like...

store.write({
  ...store.read(),
  roses:"white"
})

...in favour of

store.patch((state) => ({
  ...state, 
  roses.white
}))

...in fact Typescript features mean that Typescript doesn't force inference (and hence excess property checks) of the Patcher function, without an explicit declaration like this, which is probably worse...

store.patch((state): State => ({
  ...state, 
  roses.white
}))

Consequently unless an alternative can be found, the Store API should have patch() removed before 2.0.0.