Skip to content

Commit

Permalink
replace ObservedObject with StateObject in HomeView so that it's init…
Browse files Browse the repository at this point in the history
…ialised once.
  • Loading branch information
tobitech committed Oct 8, 2024
1 parent 900f46e commit 13eed78
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions Example/SmileID/Home/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import SwiftUI
struct HomeView: View {
let version = SmileID.version
let build = Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? "Unknown"
@ObservedObject var viewModel: HomeViewModel
@ObservedObject var networkMonitor = NetworkMonitor.shared
@StateObject var viewModel: HomeViewModel

init(config: Config) {
viewModel = HomeViewModel(config: config)
_viewModel = StateObject(wrappedValue: HomeViewModel(config: config))
}

var body: some View {
Expand Down
2 changes: 1 addition & 1 deletion Sources/SmileID/Classes/SmileID.swift
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public class SmileID {
LocalStorage.getFileByType(jobId: jobId, fileType: .selfie),
LocalStorage.getFileByType(jobId: jobId, fileType: .documentFront),
LocalStorage.getFileByType(jobId: jobId, fileType: .documentBack),
LocalStorage.getInfoJsonFile(jobId: jobId),
LocalStorage.getInfoJsonFile(jobId: jobId)
].compactMap { $0 }
allFiles = livenessFiles + additionalFiles
} catch {
Expand Down

0 comments on commit 13eed78

Please sign in to comment.