92green / enty

Normalized State Management
MIT License
6 stars 1 forks source link

AutomaticCrow - V2 - First attempt #157

Closed allanhortle closed 3 years ago

allanhortle commented 4 years ago
* Remove Unmutable Enty
* Remove Unmutable enty-state
- Remove Unmutable react-enty
* Flatten Message
* Schema V2
- Schema entries
- Message props should match state storage
- api have both request and raw functions
- request functions return a promise with a defined api (always resolve, show type & state)
* Store: Replace reducer pattern with some kind of singleton (CreateStore)
* Store: update,remove, getRequest, getEntity
- store.foo.fetch - Handle any async type
- ttls
const store = CreateStore({
    schema: RootSchema,
    endpoints: {
        foo: () => fetch(`/foo`),
        bar: () => fetch(`/bar`)
    }
});
function App() {
    return <Provider store={store}>
        <FooProfile />
    </Provider>;
}
function FooProfile(props) {
    const foo = useMessage({
        id: props.fooId,
        request: store.foo
    });
}
store.update({});
store.remove('foo', '123');
store.updateRequestState(foo.hash(123), 'empty');
const fooEntity = store.getEntity('foo', '123');
const fooRequest = store.getRequest(foo.hash(123));
const fooResponse = store.getResponse(foo.hash(123));
store.foo.fetch({
    id: '123',
    payload: {}
});
store = {
    responseCount,
    entities {},
    requests: {}
}