Something like akita array utils? #270
-
Hi, I'm wondering if there is something like https://opensource.salesforce.com/akita/docs/additional/array but for Elf. I'm trying to replicate this example with entities but I'm a bit lost. I basically want to have arrays of entities that can be modified (the entity itself and the array by appending or removing elements). This is what I have but please bring me some light, I don't even know if I'm using Elf correctly.
My example was done based on this https://ngneat.github.io/elf/docs/features/entities/entities-props-factory but the part of "normalized state" is not providing a lot of details. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Forgot to mention that what I'm trying to do is something like this https://netbasal.com/working-with-normalized-data-in-akita-e626d4c67ca4#:~:text=In%20Akita%2C%20normalizing%20data%20means,by%20storing%20the%20entities'%20ID. |
Beta Was this translation helpful? Give feedback.
-
Elf has no array methods since I don't want to maintain it. There are libraries on the web that do the same thing. According to your example, if the entities that are changed are the comments, you should switch the stream to this: posts$ = store.pipe(
selectAllEntities({ ref: commentsEntitiesRef }),
withLatestFrom(store.pipe(selectEntities()),
map(([comments, posts]) => {
return posts.map(s => {
return {
...s,
comments: s.comments.map( commentId => {
return comments[commentId]
})
}
})
})
); |
Beta Was this translation helpful? Give feedback.
-
Thank you so much @NetanelBasal |
Beta Was this translation helpful? Give feedback.
Elf has no array methods since I don't want to maintain it. There are libraries on the web that do the same thing.
According to your example, if the entities that are changed are the comments, you should switch the stream to this: