What we mean by CRUD is the ability to add, edit, read, and delete the data from the store. The point of using the entity library is for it to do most of the heavy lifting. The time has come to revisit our reducer:
// excerpt from app.module.tsfunction userReducer( state = initial, action: ActionPayload<User>): State { switch (action.type) { case "ADD_USER": return userAdapter.addOne(action.payload, state); default: return state; }}
Here, we are using the userAdapter instance to carry out adding one item to the store. There is a lot more the adapter can do for us though—here is a full list of its capabilities:
// description of the interface for EntityStateAdapter, // the interface our userAdapter implementsexport