<BlockSwitcher>

<Block name="Async/Await">

```swift
let isSignedOut = HubFilters.forEventName(HubPayload.EventName.Auth.signedOut)
let token = Amplify.Hub.listen(to: .auth, isIncluded: isSignedOut) { payload in
    Task {
        do {
            try await Amplify.DataStore.clear()
            print("Local data cleared successfully.")
        } catch let error as DataStoreError {
            print("Error clearing DataStore \(error)")
        } catch {
            print("Unexpected error \(error)")
        }
    }
}
```

</Block>

<Block name="Combine">

```swift
let isSignedOut = HubFilters.forEventName(HubPayload.EventName.Auth.signedOut)
let sink = Amplify.Hub.publisher(for: .auth)
    .setFailureType(to: DataStoreError.self)
    .filter { isSignedOut($0) }
    .sink { _ in }
    receiveValue: { _ in
        Task {
            do {
                try await Amplify.DataStore.clear()
                print("Local data cleared successfully.")
            } catch {
                print("Local data not cleared \(error)")
            }
        }
    }
```

</Block>

</BlockSwitcher>
