> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cloneable.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Sync and network status

> Show sync status and react to network changes

## Overview

Cloneable syncs data and files with its backend services. Show users the current sync status.

## Network Status

`CloneablePlatform` provides the published `networkConnected` variable. Its value updates when network status changes:

```swift theme={null}
public enum CloneableConnectionState {
    case connecting
    case connected
    case disconnected
}

// example usage
struct CloneableStatus: View {
    @EnvironmentObject var cloneable: CloneablePlatform
    
    var body: some View {
        if cloneable.networkStatus == .disconnected {
            // show disconnected
        } else {
            // show connected
        }
    }
}
```

## Sync Status

Monitor the `syncStatus` variable for data and file sync changes. It has these states:

```swift theme={null}
public enum CloneableSyncStatus {
    case syncing
    case synced
    case sync_error
}

// example usage
struct CloneableStatus: View {
    @EnvironmentObject var cloneable: CloneablePlatform
    
    var body: some View {
        if cloneable.syncStatus == .synced {
            // show platform is synced
        } else {
            // show other cases
        }
    }
}
```

## Monitor file sync status

The published `numFilesToSync` variable reports files still waiting to sync. It is an `Int`:

```swift theme={null}
/// example usage
struct CloneableStatus: View {
    @EnvironmentObject var cloneable: CloneablePlatform
    
    var body: some View {
        if cloneable.syncStatus == .syncing {
            // Get the total number of files we still need to show
            Text(String(cloneable.numFilesToSync) + " files to sync")
        } else {
            // show other cases
        }
    }
}
```

### Get the total downloaded file count

Call `getNumberOfDownloadedFiles()` to get the total downloaded file count:

```swift theme={null}
/// example usage
struct CloneableStatus: View {
    @EnvironmentObject var cloneable: CloneablePlatform
    
    var body: some View {
        // Get the total number of files downloaded
        Text(String(cloneable.getNumberOfDownloadedFiles()) + " files downloaded")
    }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.