Replies: 2 comments 3 replies
-
Another way. import { createEntityAdapter } from "@idealjs/entity";
import { createEvent, createStore } from "effector";
interface IUser {
id: string;
name: string;
}
const $addOne = createEvent<IUser>();
const $removeOne = createEvent<string>();
const entityAdapter = createEntityAdapter<IUser>();
const store = createStore(entityAdapter.getInitialState());
const $entityStore = store
.on($addOne, (entityState, data) => {
return entityAdapter.addOne(entityState, data);
})
.on($removeOne, (entityState, data) => {
return entityAdapter.removeOne(entityState, data);
}); It can also create entity data. But redux-toolkit's entity need immer,reselect as deps. |
Beta Was this translation helpful? Give feedback.
-
I think this is a great idea. The only difficulty in implementing this idea is the need for continuous feedback from people who test the implementation in practice, on real-world tasks. So that you can ask: "Is this convenient? What if we do this? What is causing difficulties?" Not so long ago I tried to implement an api for working with collections (queries, filtering; most likely we will want to do more than just add and remove items, right?), but without feedback it was purely an abstract experiment. Notice how the target UI looks like — the key trick is that the editable and collapsible tree squeezes the most out of the approach And how would you implement such a task? I found that a lot of issues comes in an interaction between api itself and the view |
Beta Was this translation helpful? Give feedback.
-
I am looking for a eaiser api to create store like redux toolkit's createEntityAdapter.
What about createEntityStore?
Beta Was this translation helpful? Give feedback.
All reactions