Skip to content
This repository has been archived by the owner on Sep 24, 2024. It is now read-only.

Commit

Permalink
docs: ✏️ no cleanup logic in onDisappear
Browse files Browse the repository at this point in the history
BREAKING CHANGE: 🧨 for previous releases it was suggested to implement cleanup logic in
`onDisappear` but you cannot rely that `onDisappear` will be called only
once. The `AssistantView` might trigger further navigations causing the
`AssistantView` to disappear and re-appear. Therefore cleanup logic
should be handled elsewhere.
  • Loading branch information
MarcoEidinger committed Nov 1, 2021
1 parent db9cf84 commit fa97ee2
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,10 @@ AssistantView()
.environmentObject(viewModel)
.environmentObject(ThemeManager.shared)
.onDisappear {
viewModel.cancelSubscriptions()
dataPublisher.resetConversation()
//SAPCAI uses `SDWebImage` and its image caching capabilities but it is the app developers responsibility to clear the cache if that is desired
SDImageCache.shared.clearMemory()
SDImageCache.shared.clearDisk(onCompletion: nil)
// you cannot rely that onDisappear will be called only once
// because `AssistantView` might trigger further navigations
// causing the `AssistantView` to disappear and re-appear.
// Therefore cleanup logic should be handled elsewhere.
})
```

Expand All @@ -161,6 +160,21 @@ let vc = MessagingViewController(MessagingViewModel(publisher: dataPublisher))
self.navigationController?.pushViewController(vc, animated: true)
```

### Cleanup

Once a conversation ended you need to call the following functions to avoid memory leaks and unnecessary network requests. Also `MessagingViewModel` cannot be deallocated otherwise.

```swift
viewModel.cancelSubscriptions()
dataPublisher.resetConversation()
```

SAPCAI uses `SDWebImage` and its image caching capabilities but it is the app developers responsibility to clear the cache if that is desired. Example:
```Swift
SDImageCache.shared.clearMemory()
SDImageCache.shared.clearDisk(onCompletion: nil)
```

## Theming

`SAPCAI` will provide two standard themes
Expand Down

0 comments on commit fa97ee2

Please sign in to comment.