Search code examples
angularngrxangular-ngrx-datangrx-data

Understanding capabilities of ngrx/data


I'm trying to get familiar with ngrx/data but I'm not sure about its capabilities. I've read the documentation and some tutorials but there are still a lot of question marks:

  1. ngrx/data offers methods for CRUD functionality. But what about additional non-CRUD requests? Is it possible to extend ngrx/data for non-CRUD requests (for example a login request or something) and to implement own actions, reducers and effects for this? Which part of ngrx/data must be extended? EntityAction? EntityCollectionService? EntityCollectionReducer? The documentation about these things is a little bit confusing and I don't really understand how all these parts work together. Maybe someone can give some clarification about this and provide some sample code.

  2. In my Angular project I'm using the "traditional" store/actions/reducers/effects pattern. Sometimes an effect is triggered on multiple actions (for example, a successful update action triggers an re-read from the server). Is it possible to achieve this behavior also with ngrx/data?

  3. Is it possible to use ngrx/data and the "traditional" store pattern together on the same store entities? ngrx/data for the CRUD operations and store/actions/reducers/effects for the non-CRUD operations?

Some hints and thoughts would be helpful. Thanks :)


Solution

    1. for login and other not crud things you should use normal ngrx/store interface with actions, reducers and effects.

    2. ngrx/data is the same set of store/actions/reducers/effects, you can write an effect that listens on actions of ngrx/data and performs side effects you want.

    3. yes, see the second answer. ngrx/data is just a set of store/actions/reducers/effects that are wrapped by services.