Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Smaller README refactoring #153

Merged
merged 1 commit into from
May 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,7 @@ val confidence = ConfidenceFactory.create(
region = ConfidenceRegion.EUROPE
)
```
Where `MY_SECRET` is an API key that can be generated in the [Confidence UI](https://confidence.spotify.com/console).

Make the initial fetching of flags using the `activateAndFetch` method. This is a suspending function that will fetch the flags from the server and activate them.
It needs to be run in a coroutine scope.

```kotlin
viewModelScope.launch {
confidence.fetchAndActivate()
}
```

<!-- TODO: add more information about activate, fetchAndActivate and fetch methods. -->
Where `MY_SECRET` is an API key that can be generated in the [Confidence UI](https://confidence.spotify.com/console)

### Setting the context
The context is a key-value map that will be used for sampling and for targeting input in assigning feature flag values by the Confidence backend. It is also a crucial way to create dimensions for metrics generated by event data.
Expand All @@ -59,7 +48,18 @@ confidence.putContext("key", ConfidenceValue.String("value")) // this will mutat
val otherConfidenceInstance = confidence.withContext("key", ConfidenceValue.String("value")) // this will return a new Confidence instance with the context changes applied but the context of the original instance is kept intact
```

### Resolving feature flags
### Fetching and resolving flags
Make the initial fetching of flags using the `activateAndFetch` method. This is a suspending function that will fetch the flags from the server and activate them.
It needs to be run in a coroutine scope.

```kotlin
viewModelScope.launch {
confidence.fetchAndActivate()
}
```

<!-- TODO: add more information about activate, fetchAndActivate and fetch methods. -->

**Once the flags are fetched and activated**, you can access their value using the `getValue` method or the `getFlag` method.
Both methods uses generics to return a type defined by the default value type.

Expand All @@ -70,7 +70,6 @@ In the case of an error, the default value will be returned and the `Evaluation`
The method `getValue` will simply return the assigned value or the default.

```kotlin

val message: String = confidence.getValue("flag-name.message", "default message")
val messageFlag: Evaluation<String> = confidence.getFlag("flag-name.message", "default message")

Expand Down
Loading