1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-04 00:18:01 +01:00

feat: now code examples are joined into one (#8284)

Joined all examples into one copyable example.

Did not do following ones, because they are using templates and probably
will not work as joined.

1. React
2. Svelte
3. Vue

Also skipped, because those examples are not final yet.

1. .NET
2. Android



![image](https://github.com/user-attachments/assets/c8dabed4-21d0-4af9-900f-e77c5d069fe1)
This commit is contained in:
Jaanus Sellin 2024-09-27 10:28:12 +03:00 committed by GitHub
parent d1c3e3fa2c
commit b73c283e6c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 9 additions and 36 deletions

View File

@ -3,7 +3,7 @@
flutter pub add unleash_proxy_client_flutter flutter pub add unleash_proxy_client_flutter
``` ```
2\. Initialize Unleash 2\. Run Unleash
```dart ```dart
import 'package:unleash_proxy_client_flutter/unleash_proxy_client_flutter.dart'; import 'package:unleash_proxy_client_flutter/unleash_proxy_client_flutter.dart';
import 'dart:async'; import 'dart:async';
@ -14,10 +14,7 @@ final unleash = UnleashClient(
appName: 'unleash-onboarding-flutter'); appName: 'unleash-onboarding-flutter');
unleash.start(); unleash.start();
```
3\. Check feature flag status
```dart
Timer.periodic(Duration(seconds: 1), (Timer timer) { Timer.periodic(Duration(seconds: 1), (Timer timer) {
final flagStatus = unleash.isEnabled('<YOUR_FLAG>'); final flagStatus = unleash.isEnabled('<YOUR_FLAG>');
print('Flag is ${unleash.isEnabled("<YOUR_FLAG>") ? "enabled" : "disabled"}'); print('Flag is ${unleash.isEnabled("<YOUR_FLAG>") ? "enabled" : "disabled"}');

View File

@ -3,7 +3,7 @@
go get github.com/Unleash/unleash-client-go/v3 go get github.com/Unleash/unleash-client-go/v3
``` ```
2\. Initialize Unleash 2\. Run Unleash
```go ```go
import ( import (
"github.com/Unleash/unleash-client-go/v3" "github.com/Unleash/unleash-client-go/v3"
@ -20,10 +20,7 @@ func init() {
unleash.WithMetricsInterval(5*time.Second), unleash.WithMetricsInterval(5*time.Second),
) )
} }
```
3\. Check feature flag status
```go
func main() { func main() {
for { for {
unleash.IsEnabled("<YOUR_FLAG>") unleash.IsEnabled("<YOUR_FLAG>")

View File

@ -7,7 +7,7 @@
</dependency> </dependency>
``` ```
2\. Initialize Unleash 2\. Run Unleash
```java ```java
UnleashConfig config = UnleashConfig.builder() UnleashConfig config = UnleashConfig.builder()
.appName("unleash-onboarding-java") .appName("unleash-onboarding-java")
@ -18,10 +18,7 @@ UnleashConfig config = UnleashConfig.builder()
.build(); .build();
Unleash unleash = new DefaultUnleash(config); Unleash unleash = new DefaultUnleash(config);
```
3\. Check feature flag status
```java
while (true) { while (true) {
boolean featureEnabled = unleash.isEnabled("<YOUR_FLAG>"); boolean featureEnabled = unleash.isEnabled("<YOUR_FLAG>");
System.out.println("Feature enabled: " + featureEnabled); System.out.println("Feature enabled: " + featureEnabled);

View File

@ -3,7 +3,7 @@
npm install unleash-proxy-client npm install unleash-proxy-client
``` ```
2\. Initialize Unleash 2\. Run Unleash
```js ```js
const { UnleashClient } = require('unleash-proxy-client'); const { UnleashClient } = require('unleash-proxy-client');
@ -15,10 +15,7 @@ const unleash = new UnleashClient({
}); });
unleash.start(); unleash.start();
```
3\. Check feature flag status
```js
setInterval(() => { setInterval(() => {
console.log('Is enabled', unleash.isEnabled('<YOUR_FLAG>')); console.log('Is enabled', unleash.isEnabled('<YOUR_FLAG>'));
}, 1000); }, 1000);

View File

@ -3,7 +3,7 @@
npm install unleash-client npm install unleash-client
``` ```
2\. Initialize Unleash 2\. Run Unleash
```js ```js
const { initialize } = require('unleash-client'); const { initialize } = require('unleash-client');
@ -13,10 +13,7 @@ const unleash = initialize({
customHeaders: { Authorization: '<YOUR_API_TOKEN>' }, customHeaders: { Authorization: '<YOUR_API_TOKEN>' },
metricsInterval: 5000, metricsInterval: 5000,
}); });
```
3\. Check feature flag status
```js
setInterval(() => { setInterval(() => {
console.log('Is enabled', unleash.isEnabled('<YOUR_FLAG>')); console.log('Is enabled', unleash.isEnabled('<YOUR_FLAG>'));
}, 1000); }, 1000);

View File

@ -18,10 +18,7 @@ $unleash = UnleashBuilder::create()
->withInstanceId('unleash-onboarding-instance') ->withInstanceId('unleash-onboarding-instance')
->withMetricsInterval(5000) ->withMetricsInterval(5000)
->build(); ->build();
```
3\. Check feature flag status
```php
while (true) { while (true) {
echo 'Feature flag is: ' . $unleash->isEnabled('<YOUR_FLAG>') . PHP_EOL; echo 'Feature flag is: ' . $unleash->isEnabled('<YOUR_FLAG>') . PHP_EOL;
sleep(1); sleep(1);

View File

@ -3,7 +3,7 @@
pip install UnleashClient pip install UnleashClient
``` ```
2\. Initialize Unleash 2\. Run Unleash
```python ```python
from UnleashClient import UnleashClient from UnleashClient import UnleashClient
import asyncio import asyncio
@ -15,10 +15,7 @@ client = UnleashClient(
custom_headers={'Authorization': '<YOUR_API_TOKEN>'}) custom_headers={'Authorization': '<YOUR_API_TOKEN>'})
client.initialize_client() client.initialize_client()
```
3\. Check feature flag status
```python
while True: while True:
print(client.is_enabled("<YOUR_FLAG>")) print(client.is_enabled("<YOUR_FLAG>"))
asyncio.run(asyncio.sleep(1)) asyncio.run(asyncio.sleep(1))

View File

@ -3,7 +3,7 @@
gem install unleash gem install unleash
``` ```
2\. Initialize Unleash 2\. Run Unleash
```rb ```rb
require 'unleash' require 'unleash'
@ -15,10 +15,7 @@ require 'unleash'
refresh_interval: 3, # In production use interval of >15s refresh_interval: 3, # In production use interval of >15s
metrics_interval: 3, # In production use interval of >15s metrics_interval: 3, # In production use interval of >15s
) )
```
3\. Check feature flag status
```rb
while true while true
if @unleash.is_enabled?("<YOUR_FLAG>") if @unleash.is_enabled?("<YOUR_FLAG>")
puts "Flag is enabled" puts "Flag is enabled"

View File

@ -7,7 +7,7 @@ cargo add serde tokio --features full
cargo add serde anyhow cfg cfg-if enum-map@~2.0.0 surf cargo add serde anyhow cfg cfg-if enum-map@~2.0.0 surf
``` ```
2\. Initialize Unleash 2\. Run Unleash
```rust ```rust
use enum_map::Enum; use enum_map::Enum;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View File

@ -4,7 +4,7 @@
https://github.com/Unleash/unleash-proxy-client-swift.git https://github.com/Unleash/unleash-proxy-client-swift.git
``` ```
2\. Initialize Unleash 2\. Run Unleash
```swift ```swift
import Foundation import Foundation
import UnleashProxyClientSwift import UnleashProxyClientSwift
@ -17,10 +17,7 @@ var unleash = UnleashProxyClientSwift.UnleashClient(
context: [:]) context: [:])
unleash.start() unleash.start()
```
3\. Check feature flag status
```swift
Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { _ in Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { _ in
print("Is enabled", unleash.isEnabled(name: "<YOUR_FLAG>")) print("Is enabled", unleash.isEnabled(name: "<YOUR_FLAG>"))
} }