Longhand Lenses
Explore how longhand lenses in RamdaJS work by combining getter and setter functions. Learn to use prop and assoc for precise, immutable manipulation of object properties without mutation.
We'll cover the following...
We'll cover the following...
lensProp and lensIndex are actually built on top of the lower-level lens function.
This
Is a convenient shorthand for this
See the difference?
Why prop() and assoc()?
Ramda’s prop function lets you get object properties.
And assoc lets you set them without mutating the original object.
And since lenses need a getter and a setter to perform their duties, prop and assoc make the perfect combination to immutably handle and change lenses.