Focusable atoms (optics for this lib)
See original GitHub issueHello,
Interesting library!
Would it be possible for you to provide utilities for using this in conjunction with a optics library? My idea for a pretty nice api would be:
const bigAtom: WritableAtom<{myKey: number[]}> = atom({myKey: [1,2,3]})
const focusedAtom: WritableAtom<number> = bigAtom.focus(optic => optic.prop('myKey').index(0))
Or even:
const bigAtom: WritableAtom<{myKey: 10}> = atom({myKey: 10})
const focusedAtom: WritableAtom<number> = bigAtom.prop('myKey').index(0)
The optics library I like is https://github.com/akheron/optics-ts
The idea is that if any of the focused atoms are “set”, then the big atom is updated, leading to a update to the focused atom.
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Optics — Jotai, primitive and flexible state management for ...
focusAtom creates a new atom, based on the focus that you pass to it. This creates a derived atom that will focus on...
Read more >NIST Researchers Develop Miniature Lens for Trapping Atoms
These imprinted surfaces, dubbed metasurfaces, focus laser light to trap, manipulate and image individual atoms within a vapor.
Read more >An ellipsoidal mirror for focusing of neutral atomic and ...
Manipulation of atomic and molecular beams is essential to atom optics ... have been used to focus a beam of neutral helium atoms...
Read more >ARC: An open-source library for calculating properties of alkali ...
Abstract: We present an object-oriented Python library for computation of properties of highly-excited Rydberg states of alkali atoms.
Read more >Single-Atom Trapping in a Metasurface-Lens Optical Tweezer
A metasurface lens is used to trap and image single atoms, ... that leverage ongoing advances in element design libraries and in multilayer ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
Top Related Hashnode Post
No results found
Nope! I think this is the way it’s supposed to work.
If an optional focus (Prism) does not have a value, the setter does nothing.
According to the
optics-ts
docs (which is used here), here’s the explaination of theoptional
: https://akheron.github.io/optics-ts/reference-mc/#optionalIf I’ve understood it correctly, it means that it only focuses on the non-undefined case - if it’s another case, then it does nothing. In this case, it’s undefined, so it does nothing!
I hope that was of help, and if I can assist with something else or elborate further, please ask 😄
Looks about right (typing it will be interesting, since some optics are ReadOnly, and some are removable).
Thanks, I think this resolves my issue.