-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Update example app with the latest local SDK version * Checkpoint commit, SSE connection up and running, need to implement the decoding and logic * Attempt to decode the SSE data * Initial implementation of the logic from the Kotlin implementation * Add a SwiftUI view to the example app to show real-time updates to the flags * Fix an issue with taking too many event stream updated-at times * Swift lint and tidy up * Add some unit tests for the SSEManager class and also change the reconnection logic to use a backoff timer * Tidy and document SSEManager * A bit of a tidy and swift linting * Removed some commented-out code and put some back in * Run swift format and update the swift format package * Update FlagsmithClient/Tests/SSEManagerTests.swift Co-authored-by: Matthew Elwell <[email protected]> * Updated use of API Key -> env * Remove the unnecessary Podfile.lock from the example app --------- Co-authored-by: Matthew Elwell <[email protected]>
- Loading branch information
1 parent
ba0fb2b
commit c7330df
Showing
24 changed files
with
948 additions
and
373 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Example/FlagsmithClient.xcodeproj/xcshareddata/xcschemes/FlagsmithClient_Example.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// | ||
// SwiftUIView.swift | ||
// FlagsmithClient_Example | ||
// | ||
// Created by Gareth Reese on 16/09/2024. | ||
// Copyright © 2024 CocoaPods. All rights reserved. | ||
// | ||
|
||
#if canImport(SwiftUI) | ||
import SwiftUI | ||
#endif | ||
import FlagsmithClient | ||
|
||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) | ||
struct SwiftUIView: View { | ||
@State private var flags: [Flag] = [] | ||
@State private var isLoading = true | ||
|
||
let flagsmith = Flagsmith.shared | ||
|
||
var body: some View { | ||
VStack { | ||
if isLoading { | ||
ProgressView() | ||
} else { | ||
Text("Feature Flags") | ||
.font(.title) | ||
.padding() | ||
List(flags, id: \.feature.name) { flag in | ||
HStack { | ||
Text("\(flag.feature.name): \(flag.value)") | ||
Spacer() | ||
Text("\(flag.enabled ? "✅" : "❌")") | ||
} | ||
} | ||
} | ||
} | ||
.onAppear { | ||
initializeFlagsmith() | ||
subscribeToFlagUpdates() | ||
} | ||
} | ||
|
||
func initializeFlagsmith() { | ||
// Fetch initial flags | ||
flagsmith.getFeatureFlags { result in | ||
DispatchQueue.main.async { | ||
switch result { | ||
case .success(let fetchedFlags): | ||
flags = fetchedFlags | ||
case .failure(let error): | ||
print("Error fetching flags: \(error)") | ||
} | ||
isLoading = false | ||
} | ||
} | ||
} | ||
|
||
func subscribeToFlagUpdates() { | ||
Task { | ||
for await updatedFlags in flagsmith.flagStream { | ||
DispatchQueue.main.async { | ||
flags = updatedFlags | ||
} | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.