Is it possible to have a dynamic set of entities using @ngrx/entity? If so, how is it done? If not, what is the best practice for handling this situation?
Example
I have dynamic list of contracts I receive from the back-end. Under each contract I have a table of transactions that I load one by one as they are viewed. I would like to use @ngrx/entity for the line-items on this table, but because it's dynamic I don't know how to define them. here is a design:
The only solution I can think of is to only have one entity adapter and replace the table rows each time an accordion opens. I would enforce only one open at a time. I would also have to copy off the entities when one closes so I wouldn't lose data already loaded.
The other option I can think of without using @ngrx/entity and use the same pattern to have the contract entities and then under each of those line-item entities.
I don't know what you mean with dynamic entities in this context.
I would have 2 entities: ParentEntities
, LineEntities
.
You start with loading ParentEntities
after you expand a row you can fetch the LineEntities
and start populating the state.
With selectors, you can combine parent entities with their line entities. With this data, you can render your view.