Skip to content

Latest commit

 

History

History
8 lines (4 loc) · 1.13 KB

README.md

File metadata and controls

8 lines (4 loc) · 1.13 KB

Lenses 👓 & Hooks 🎣

🎯 Ambitious goals: The aim of this session/workshop/whatever-it-is is to implement a custom React hook that will utilize lenses for state management. The inspiration is André Staltz's use-profunctor-state library. Here's the accompanying talk: "Profunctor Optics for State Management".

To be honest, I don't really know what profunctors are all about (and maybe André doesn't either?), but I think we should be able to implement something similar with regular old lenses brought in from ramda or partial.lenses. We could also try implementing our own set/view/over functions from scratch (or, mostly from scratch, as it probably would be easier to rely on optics implementations from one of the above libraries).

The idea is that you can replace Redux with a top-level state object and use lenses to get and set from state. At least, that's the promise, but I don't know—I am still learning Redux so we'll see how this goes 😉.