From b73c283e6c582b62ddd1427272c950a073f305b4 Mon Sep 17 00:00:00 2001 From: Jaanus Sellin Date: Fri, 27 Sep 2024 10:28:12 +0300 Subject: [PATCH] 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) --- frontend/src/component/onboarding/dialog/snippets/flutter.md | 5 +---- frontend/src/component/onboarding/dialog/snippets/go.md | 5 +---- frontend/src/component/onboarding/dialog/snippets/java.md | 5 +---- .../src/component/onboarding/dialog/snippets/javascript.md | 5 +---- frontend/src/component/onboarding/dialog/snippets/nodejs.md | 5 +---- frontend/src/component/onboarding/dialog/snippets/php.md | 3 --- frontend/src/component/onboarding/dialog/snippets/python.md | 5 +---- frontend/src/component/onboarding/dialog/snippets/ruby.md | 5 +---- frontend/src/component/onboarding/dialog/snippets/rust.md | 2 +- frontend/src/component/onboarding/dialog/snippets/swift.md | 5 +---- 10 files changed, 9 insertions(+), 36 deletions(-) diff --git a/frontend/src/component/onboarding/dialog/snippets/flutter.md b/frontend/src/component/onboarding/dialog/snippets/flutter.md index 146b9b1f38..43bea5e18b 100644 --- a/frontend/src/component/onboarding/dialog/snippets/flutter.md +++ b/frontend/src/component/onboarding/dialog/snippets/flutter.md @@ -3,7 +3,7 @@ flutter pub add unleash_proxy_client_flutter ``` -2\. Initialize Unleash +2\. Run Unleash ```dart import 'package:unleash_proxy_client_flutter/unleash_proxy_client_flutter.dart'; import 'dart:async'; @@ -14,10 +14,7 @@ final unleash = UnleashClient( appName: 'unleash-onboarding-flutter'); unleash.start(); -``` -3\. Check feature flag status -```dart Timer.periodic(Duration(seconds: 1), (Timer timer) { final flagStatus = unleash.isEnabled(''); print('Flag is ${unleash.isEnabled("") ? "enabled" : "disabled"}'); diff --git a/frontend/src/component/onboarding/dialog/snippets/go.md b/frontend/src/component/onboarding/dialog/snippets/go.md index a77f2e1964..63170c00cf 100644 --- a/frontend/src/component/onboarding/dialog/snippets/go.md +++ b/frontend/src/component/onboarding/dialog/snippets/go.md @@ -3,7 +3,7 @@ go get github.com/Unleash/unleash-client-go/v3 ``` -2\. Initialize Unleash +2\. Run Unleash ```go import ( "github.com/Unleash/unleash-client-go/v3" @@ -20,10 +20,7 @@ func init() { unleash.WithMetricsInterval(5*time.Second), ) } -``` -3\. Check feature flag status -```go func main() { for { unleash.IsEnabled("") diff --git a/frontend/src/component/onboarding/dialog/snippets/java.md b/frontend/src/component/onboarding/dialog/snippets/java.md index 93d714c1c2..ed41182a6f 100644 --- a/frontend/src/component/onboarding/dialog/snippets/java.md +++ b/frontend/src/component/onboarding/dialog/snippets/java.md @@ -7,7 +7,7 @@ ``` -2\. Initialize Unleash +2\. Run Unleash ```java UnleashConfig config = UnleashConfig.builder() .appName("unleash-onboarding-java") @@ -18,10 +18,7 @@ UnleashConfig config = UnleashConfig.builder() .build(); Unleash unleash = new DefaultUnleash(config); -``` -3\. Check feature flag status -```java while (true) { boolean featureEnabled = unleash.isEnabled(""); System.out.println("Feature enabled: " + featureEnabled); diff --git a/frontend/src/component/onboarding/dialog/snippets/javascript.md b/frontend/src/component/onboarding/dialog/snippets/javascript.md index 0b7785a4de..d575ebfbef 100644 --- a/frontend/src/component/onboarding/dialog/snippets/javascript.md +++ b/frontend/src/component/onboarding/dialog/snippets/javascript.md @@ -3,7 +3,7 @@ npm install unleash-proxy-client ``` -2\. Initialize Unleash +2\. Run Unleash ```js const { UnleashClient } = require('unleash-proxy-client'); @@ -15,10 +15,7 @@ const unleash = new UnleashClient({ }); unleash.start(); -``` -3\. Check feature flag status -```js setInterval(() => { console.log('Is enabled', unleash.isEnabled('')); }, 1000); diff --git a/frontend/src/component/onboarding/dialog/snippets/nodejs.md b/frontend/src/component/onboarding/dialog/snippets/nodejs.md index 0763726e5e..5ea2523b1e 100644 --- a/frontend/src/component/onboarding/dialog/snippets/nodejs.md +++ b/frontend/src/component/onboarding/dialog/snippets/nodejs.md @@ -3,7 +3,7 @@ npm install unleash-client ``` -2\. Initialize Unleash +2\. Run Unleash ```js const { initialize } = require('unleash-client'); @@ -13,10 +13,7 @@ const unleash = initialize({ customHeaders: { Authorization: '' }, metricsInterval: 5000, }); -``` -3\. Check feature flag status -```js setInterval(() => { console.log('Is enabled', unleash.isEnabled('')); }, 1000); diff --git a/frontend/src/component/onboarding/dialog/snippets/php.md b/frontend/src/component/onboarding/dialog/snippets/php.md index 1aec6312c7..636a7fa1b3 100644 --- a/frontend/src/component/onboarding/dialog/snippets/php.md +++ b/frontend/src/component/onboarding/dialog/snippets/php.md @@ -18,10 +18,7 @@ $unleash = UnleashBuilder::create() ->withInstanceId('unleash-onboarding-instance') ->withMetricsInterval(5000) ->build(); -``` -3\. Check feature flag status -```php while (true) { echo 'Feature flag is: ' . $unleash->isEnabled('') . PHP_EOL; sleep(1); diff --git a/frontend/src/component/onboarding/dialog/snippets/python.md b/frontend/src/component/onboarding/dialog/snippets/python.md index 2a013fb9b9..a1f57952c8 100644 --- a/frontend/src/component/onboarding/dialog/snippets/python.md +++ b/frontend/src/component/onboarding/dialog/snippets/python.md @@ -3,7 +3,7 @@ pip install UnleashClient ``` -2\. Initialize Unleash +2\. Run Unleash ```python from UnleashClient import UnleashClient import asyncio @@ -15,10 +15,7 @@ client = UnleashClient( custom_headers={'Authorization': ''}) client.initialize_client() -``` -3\. Check feature flag status -```python while True: print(client.is_enabled("")) asyncio.run(asyncio.sleep(1)) diff --git a/frontend/src/component/onboarding/dialog/snippets/ruby.md b/frontend/src/component/onboarding/dialog/snippets/ruby.md index 1fc136151e..fac0eadd52 100644 --- a/frontend/src/component/onboarding/dialog/snippets/ruby.md +++ b/frontend/src/component/onboarding/dialog/snippets/ruby.md @@ -3,7 +3,7 @@ gem install unleash ``` -2\. Initialize Unleash +2\. Run Unleash ```rb require 'unleash' @@ -15,10 +15,7 @@ require 'unleash' refresh_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 if @unleash.is_enabled?("") puts "Flag is enabled" diff --git a/frontend/src/component/onboarding/dialog/snippets/rust.md b/frontend/src/component/onboarding/dialog/snippets/rust.md index 6826f5db61..de2ab1b346 100644 --- a/frontend/src/component/onboarding/dialog/snippets/rust.md +++ b/frontend/src/component/onboarding/dialog/snippets/rust.md @@ -7,7 +7,7 @@ cargo add serde tokio --features full cargo add serde anyhow cfg cfg-if enum-map@~2.0.0 surf ``` -2\. Initialize Unleash +2\. Run Unleash ```rust use enum_map::Enum; use serde::{Deserialize, Serialize}; diff --git a/frontend/src/component/onboarding/dialog/snippets/swift.md b/frontend/src/component/onboarding/dialog/snippets/swift.md index d7dadce583..5448b985a4 100644 --- a/frontend/src/component/onboarding/dialog/snippets/swift.md +++ b/frontend/src/component/onboarding/dialog/snippets/swift.md @@ -4,7 +4,7 @@ https://github.com/Unleash/unleash-proxy-client-swift.git ``` -2\. Initialize Unleash +2\. Run Unleash ```swift import Foundation import UnleashProxyClientSwift @@ -17,10 +17,7 @@ var unleash = UnleashProxyClientSwift.UnleashClient( context: [:]) unleash.start() -``` -3\. Check feature flag status -```swift Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { _ in print("Is enabled", unleash.isEnabled(name: "")) }