4

I'm working on an app similar to Trello in that it needs to pull data from the server as soon as it's added by other users. There is no need to send data back using the same channel, so Server-Sent Events (unidirectional) push technology seems more appropriate to use here than WebSocket.

The App is a cross-platform React Native (expo managed) project that displays a list of items from the server with options to add, update, and delete. For now, it will work only while an internet connection is available. 

Locally, data will be stored in a redux store (RTK Toolkit). The way the app will keep the redux store up to date is: Establish an open connection to the server using SSE (Server-Sent Events) and listen for events. Use RTK Query to fetch, update, and delete data. On receiving an SSE event (an event with information that new data is available on the server, updates were done by someone else), the app will clear the local RTK Query cache and fetch the whole data set again from the server.

There are several concerning issues that could affect the performance and usability: 

  1. Downloading the entire data set in response to any type of update event (new/updated/deleted item by another user) will retrieve the entire list, which may contain many items with nested ones. It doesn't seem to be an effective approach. Especially if another user performs multiple minor changes (changes name, persists, changes date, persists, adds description, persists...), this will result in at least 3 update events.

  2. After performing an action on your own, the entire data set will be downloaded. I.e., a user adds a new item, there is a call POST to the server, the server pushes events, and the user gets an event that there is newer data on the server. RTK Query's cache will be reset and a new dataset will be fetched and stored in redux. 

I don't have that extensive experience with React Native, so I would like to ask more seasoned veterans if this solution can actually work and how it can be improved.

Many thanks.

0 Answers0