Skip to content

Instantly share code, notes, and snippets.

@rolandpeelen
Last active August 18, 2019 14:51
Show Gist options
  • Select an option

  • Save rolandpeelen/a25b4c9d689085cc2e69b45d991cb36a to your computer and use it in GitHub Desktop.

Select an option

Save rolandpeelen/a25b4c9d689085cc2e69b45d991cb36a to your computer and use it in GitHub Desktop.
import { lensPath, lensProp, compose } from 'ramda';
const objectsLens = lensPath(['scene', 'structure', 'objects']);
const groupsLens = lensPath(['scene', 'structure', 'groups']);
// If you use lenses all over the place, you may have some laying around allready, like these
const sceneLens = lensProp('scene');
const structureLens = lensProp('structure');
const objectsLens = lensProp('objects');
const groupsLens = lensProp('groups');
// If so, we could make those top ones even easier
const structureObjectLens = compose(sceneLens, structureLens, objectsLens);
const structureGroupLens = compose(sceneLens, structureLens, groupsLens);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment