merisbahti / klyva

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

Add slice-atom-object #37

Closed krawaller closed 3 years ago

krawaller commented 3 years ago

We add sliceAtomObject to match the existing sliceAtomArray. In other words we take an object and return a new object where the values are wrapped in removable atoms!

const objAtom = atom({ foo: 'hello', bar: 9 });
const { foo, bar } = sliceAtomObject(objAtom);

foo.update('world');
bar.remove();

expect(objAtom.getValue()).toEqual({ foo: 'world' });
codesandbox-ci[bot] commented 3 years ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 4acd7abd9195ff800fe4be9d25e1d18f3f4b35bc:

Sandbox Source
React Configuration
React Typescript Configuration