vana
vana copied to clipboard
Change how "bind" works with objects
Currently, an object lens (created with bind) can only be replaced. Merging and/or drafting must be done with the revise function, which isn't awful, but we could do better.
const foo = o({ bar: { a: 0, b: 0 } })
const barLens = bind(foo, 'bar')
// Merge new values
barLens({ a: 1 })
// Overwrite all values
barLens(() => ({ a: 1, b: 1 }))
// Make edits with a producer
barLens(draft => {
draft.a++
draft.b++
})
Object merging was added in v0.5.1 🎉
But producers are not yet supported