merisbahti / klyva

A state management library that follows the React component model
MIT License
55 stars 4 forks source link

Extract slice-atom-array from react-utils #18

Closed krawaller closed 3 years ago

krawaller commented 3 years ago

The sliceAtomArray helper isn't React specific, so shouldn't hide inside react-utils

merisbahti commented 3 years ago

Hmm I was thinking about this before, but there's a footgun with doing this:

The sliced array stays static, even if items are added or removed.

So the "obvious" solution would be to create some kind of Atom which contains this list, which is updated as soon as the input-atom (Atom<Array<Element>>) is changed.

I tried doing that this morning but I get infinite updates problem in react, going to investigate

krawaller commented 3 years ago

I agree that sliceAtomArray is low-level, and would benefit from further wrappers.

But those wrappers can be React-specific, or Svelte-specific, or just framework agnostic like sliceAtomArray itself. It still isn't tied to React?