From 485e017e340740e29cab0bcd51606278c97d12d7 Mon Sep 17 00:00:00 2001 From: Michael Jarecki <4808737+superguineapig@users.noreply.github.com> Date: Thu, 13 Dec 2018 14:33:07 -0600 Subject: [PATCH] Improve setOnline example --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cc4af5c..6168dc5 100644 --- a/README.md +++ b/README.md @@ -250,8 +250,13 @@ const config = { const clock = new clockSync(config); -// this handler will receive the device's network status -function handleConnectivityChange = isConnected => { +// set initial state +NetInfo.isConnected.fetch().then(isConnected => { + clock.setOnline(isConnected); +}); + +// this handler will receive the device's network status changes +function handleConnectivityChange (isConnected) { clock.setOnline(isConnected); }