refactor: store file content in atom#105
Conversation
danvk
left a comment
There was a problem hiding this comment.
Nice to see the atoms wired up! Lots of suggestions but at a high level:
- Now that #100 is in, this really needs some tests. It would be great to have tests for some of the invariants that you're maintaining, for example that a file gets purged from memory once it's closed in both panes. OK if it's in another PR, but it should probably the very next PR!
- I think we should use an eslint rule to enforce that "core" atoms are only used in the expected places, rather than relying on comments and underscores. See comment below.
- I believe Jotai's
atomFamilyis designed to eliminate some of the bookkeeping aroundMaps.
It's less scary to refactor once you have tests, so maybe a path forward could be to add some unit tests for src/atoms/fileActions.ts (the public state API) and then refactor the internals to use atomFamily.
|
Thank you for these comments. I have addressed them |
This PR fixes #32
This splits the state in a more atomic way, with the following:
This also adds an
activePanestate, that enables the app to open new file in the pane that has been used in last.