Start sharing components as a team!Share components as a team!Join Bit to build your applications faster.Get Started Free

lens

v0.26.1arrow_drop_down
v0.26.1
STATUS
Passing
DOWNLOADS
35
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
7 months ago
SIZE
2 KB
subject
Returns a lens for the given getter and setter functions.
1 contributor
Use lens in your project ?
Copied
npm i @bit/ramda.ramda.lens
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
Component Example
React
React
Vue
Angular
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
revert changes
reload
toggle layout
maximize
view(xLens, {
  x: 1,
  y: 2
});
modifieddraft
chevron_left
chevron_right
lens (
getter:Function,
setter:Function
) : Lens

Returns a lens for the given getter and setter functions. The getter “gets” the value of the focus; the setter “sets” the value of the focus. The setter should not mutate the data structure.

Example
const xLens = R.lens(R.prop('x'), R.assoc('x'));

     R.view(xLens, {x: 1, y: 2});            //=> 1
     R.set(xLens, 4, {x: 1, y: 2});          //=> {x: 4, y: 2}
     R.over(xLens, R.negate, {x: 1, y: 2});  //=> {x: -1, y: 2}
Arguments
getter: Function
setter: Function
Returns
Lens