handling sync via global state, register and unregister functions handle sync on the api