Created
July 21, 2019 21:45
-
-
Save juucustodio/5f1e31427b8da629d12cc0730c4489f3 to your computer and use it in GitHub Desktop.
Example of how to use Feature Toggle in your Xamarin.Forms applications.
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
using System.ComponentModel; | |
using ConfigCat.Client; | |
using Xamarin.Forms; | |
namespace DemoFeatureToggle | |
{ | |
[DesignTimeVisible(false)] | |
public partial class MainPage : ContentPage | |
{ | |
LazyLoadConfiguration clientConfiguration = new LazyLoadConfiguration | |
{ | |
ApiKey = "API KEY", | |
CacheTimeToLiveSeconds = 240 | |
}; | |
IConfigCatClient client; | |
public MainPage() | |
{ | |
InitializeComponent(); | |
client = new ConfigCatClient(clientConfiguration); | |
} | |
void Handle_Clicked(object sender, System.EventArgs e) | |
{ | |
if (client.GetValue("isAwesomeFeatureEnabled", false)) | |
{ | |
LblResult.Text = "ON"; | |
LblResult.TextColor = Color.GreenYellow; | |
} | |
else | |
{ | |
LblResult.Text = "OFF"; | |
LblResult.TextColor = Color.Red; | |
} | |
} | |
protected override void OnDisappearing() | |
{ | |
base.OnDisappearing(); | |
client.Dispose(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment