Fixes #1

Listen to online/offline events to trigger sync if needed