consider this scenario:
I fetch conversations from /conversations
endpoint. The response is in this format:
{
total:100,
conversations: [
...// an array of conversations which is a portion of data
]
}
I save fetched conversations and total number in global state in this way:
{
conversations: [],
total: 100,
}
In my app the conversations
array is constantly being changed in different places. being added, subtracted and … with multiple actions.
I was thinking about a cleaner way for updating total
just by observing change in conversations
in array one place and changing total
based on it’s change instead of manually updating it.
Is there any way?