Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/configcat/docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sigewuzhere committed Feb 5, 2020
2 parents 27a6e93 + f8b63db commit 5ddac50
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 27 deletions.
17 changes: 10 additions & 7 deletions docs/sdk-reference/android.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ val client = ConfigCatClient("#YOUR-API-KEY#")
```
### 4. Get your setting value
```kotlin
val isMyAwesomeFeatureEnabled = client.getValue(Boolean::class.javaObjectType, "<key-of-my-awesome-feature>", false)
val isMyAwesomeFeatureEnabled = client.getValue(Boolean::class.java "<key-of-my-awesome-feature>", false)
if(isMyAwesomeFeatureEnabled) {
doTheNewThing()
} else {
Expand Down Expand Up @@ -82,7 +82,7 @@ val client = ConfigCatClient.newBuilder()
| `defaultValue` | **REQUIRED.** This value will be returned in case of an error. |
```kotlin
val value = client.getValue(
Boolean::class.javaObjectType, // Setting type
Boolean::class.java, // Setting type
"keyOfMySetting", // Setting Key
User.newBuilder().build("435170f4-8a8b-4b67-a723-505ac7cdea92"), // Optional User Object
false // Default value
Expand All @@ -98,7 +98,7 @@ val value = client.getValue(
| `defaultValue` | **REQUIRED.** This value will be returned in case of an error. |
```kotlin
client.getValueAsync(
Boolean::class.javaObjectType, // Setting type
Boolean::class.java, // Setting type
"keyOfMySetting", // Setting Key
User.newBuilder().build("435170f4-8a8b-4b67-a723-505ac7cdea92"), // Optional User Object
false // Default value
Expand Down Expand Up @@ -158,9 +158,8 @@ Adding a callback to `configurationChangeListener` option parameter will get you
val client = ConfigCatClient.newBuilder()
.mode(PollingModes.AutoPoll(
120 /* polling interval in seconds */,
{parser, newConfiguration ->
// here you can parse the new configuration like this:
// parser.parseValue(Boolean::class.java, newConfiguration, <key-of-my-awesome-feature>)
{
// here you can subscribe to configuration changes
})
)
.build("#YOUR-API-KEY#")
Expand Down Expand Up @@ -188,12 +187,16 @@ val client = ConfigCatClient.newBuilder()
If you set the `asyncRefresh` to `false`, the refresh operation will be awaited until the fetching of the new configuration is completed.

### Manual polling
With this policy every new configuration request on the ConfigCatClient will trigger a new fetch over HTTP.
Manual polling gives you full control over when the setting values are downloaded. ConfigCat SDK will not update them automatically. Calling `forceRefresh()` is your application's responsibility.
```java
val client = ConfigCatClient.newBuilder()
.mode(PollingModes.ManualPoll())
.build("#YOUR-API-KEY#")

client.forceRefresh()
```
> `getValue()` returns `defaultValue` if the cache is empty. Call `forceRefresh()` to update the cache.

## Custom cache

Expand Down
15 changes: 6 additions & 9 deletions docs/sdk-reference/go.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,8 @@ client := configcat.NewCustomClient(
// The auto poll interval
time.Second * 120,
// The callback called when the configuration changes
func(config string, parser *configcat.ConfigParser) {
result, err := parser.Parse(config, "key-of-my-awesome-feature")
if err != nil {
isMyAwesomeFeatureEnabled, ok := result.(bool)
if ok && isMyAwesomeFeatureEnabled {
//show your awesome feature to the world!
}
}
func() {
// here you can subscribe to configuration changes
})
)}
)
Expand All @@ -214,13 +208,16 @@ client := configcat.NewCustomClient(
>If you set the `asyncRefresh` to `false`, the refresh operation will be awaited until the fetching of the new configuration is completed.
### Manual polling
With this policy every new configuration request on the ConfigCatClient will trigger a new fetch over HTTP.
Manual polling gives you full control over when the setting values are downloaded. ConfigCat SDK will not update them automatically. Calling `Refresh()` is your application's responsibility.
```go
client := configcat.NewCustomClient(
"<PLACE-YOUR-API-KEY-HERE>",
configcat.ClientConfig{ Mode: configcat.ManualPoll() }
)

client.ForceRefresh()
```
> `GetValue()` returns `defaultValue` if the cache is empty. Call `Refresh()` to update the cache.
## Custom Cache
You have the option to inject your custom cache implementation into the client. All you have to do is to satisfy the `ConfigCache` interface:
Expand Down
12 changes: 6 additions & 6 deletions docs/sdk-reference/ios.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,8 @@ let client = ConfigCatClient(
apiKey: "<PLACE-YOUR-API-KEY-HERE>",
refreshMode: PollingModes.autoPoll(
autoPollIntervalInSeconds: 120, // polling interval in seconds
onConfigChanged: { (config, parser) in
let isMyAwesomeFeatureEnabled: String = try! parser.parseValue(for: "key-of-my-awesome-feature", json: configString)
if(isMyAwesomeFeatureEnabled) {
//show your awesome feature to the world!
}
onConfigChanged: {
// here you can subscribe to configuration changes
}
)
)
Expand Down Expand Up @@ -177,13 +174,16 @@ let client = ConfigCatClient(
If you set the `asyncRefresh` to `false`, the refresh operation will be awaited until the fetching of the new configuration is completed.

### Manual polling
With this policy every new configuration request on the ConfigCatClient will trigger a new fetch over HTTP.
Manual polling gives you full control over when the setting values are downloaded. ConfigCat SDK will not update them automatically. Calling `forceRefresh()` is your application's responsibility.
```swift
let client = ConfigCatClient(
apiKey: "<PLACE-YOUR-API-KEY-HERE>",
refreshMode: PollingModes.manualPoll()
)

client.forceRefresh()
```
> `getValue()` returns `defaultValue` if the cache is empty. Call `forceRefresh()` to update the cache.
## Custom cache
You have the option to inject your custom cache implementation into the client. All you have to do is to inherit from the `ConfigCache` open class:
Expand Down
13 changes: 8 additions & 5 deletions docs/sdk-reference/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,8 @@ Adding a callback to `configurationChangeListener` option parameter will get you
ConfigCatClient client = ConfigCatClient.newBuilder()
.mode(PollingModes.AutoPoll(
120 /* polling interval in seconds */,
(parser, newConfiguration) -> {
// here you can parse the new configuration like this:
// parser.parseValue(Boolean.class, newConfiguration, <key-of-my-awesome-feature>)
() -> {
// here you can subscribe to configuration changes
})
)
.build("<PLACE-YOUR-API-KEY-HERE>");
Expand Down Expand Up @@ -185,12 +184,16 @@ ConfigCatClient client = ConfigCatClient.newBuilder()
If you set the `asyncRefresh` to `false`, the refresh operation will be awaited until the fetching of the new configuration is completed.

### Manual polling
With this policy every new configuration request on the ConfigCatClient will trigger a new fetch over HTTP.
Manual polling gives you full control over when the setting values are downloaded. ConfigCat SDK will not update them automatically. Calling `forceRefresh()` is your application's responsibility.
```java
ConfigCatClient client = ConfigCatClient.newBuilder()
.mode(PollingModes.ManualPoll())
.build("<PLACE-YOUR-API-KEY-HERE>");
.build("#YOUR-API-KEY#");

client.forceRefresh();
```
> `getValue()` returns `defaultValue` if the cache is empty. Call `forceRefresh()` to update the cache.
## Custom cache
You have the option to inject your custom cache implementation into the client. All you have to do is to inherit from the `ConfigCache` abstract class:
```java
Expand Down

0 comments on commit 5ddac50

Please sign in to comment.