In TeamPlay, operations that modify data (like .set()
and .del()
) are asynchronous. This means they return promises that resolve when the data has been successfully synced with the server. This design ensures that your client-side data stays consistent with the server-side data.
Asynchronous setters allow TeamPlay to:
While TeamPlay automatically handles data synchronization in most cases, there might be situations where you need to ensure a specific operation has completed before proceeding. In these cases, you can await the setter operations:
In most cases, you don't need to await setters in React components. TeamPlay and React will handle updates and re-renders automatically.
Await setters when you have logic that depends on the updated data being saved to the server.
In React event handlers or effects where you're performing multiple operations, consider awaiting setters to ensure operations happen in the correct order:
By understanding and properly using asynchronous setters, you can ensure your application maintains data consistency and responds correctly to user actions.