Search code examples
reactjsvalidationreact-nativefetchinvalidation

Preventing stale data in react-native


This will be more open-minded question, maybe not limited only to react-native.

I have a typical search list that is taken from our backend. I am trying to find the best way to prevent stale data being shown for user - especially if they minimize the application and go back to it later. I was thinking about using https://github.com/ocetnik/react-native-background-timer this, but maybe there's a better way to achieve this?

Also as a quick note my stack is : react-navigation, redux, redux-persist


Solution

  • A good question, but my answer will not in the code scope.

    Data being stale whenever it was seen by user.

    At the view point of a product maker. The best way to make your data slow to being stale is "Dont show all you have".

    So, How can we implement that theory ?

    Almost of peoples do not really pay attention to what they see. They will forget anythings as soon as possible, what don't pin their eyes on.

    Thus, you don't need a timer system to check and shuffle your data. Track the user behavior is a more complex but effecient solution.

    It can be done both in your client or your server.

    Simple example:

    Store the time point when user saw your data (maybe in AsyncStorage), make a logic to check and chooose to renew or not in the next time your user come back.

    It is very simpler and lightweight solution than using timer system.

    More Complex example:

    Track the user session, type of content they view, and how much time they spend on this content.

    Replace the viewed content by the relation contents of they viewed things.

    Note: The rn-background-timer work not as good as they advertised.