Skip to content

Instantly share code, notes, and snippets.

@claudiosanchez
Last active February 14, 2019 13:45
Show Gist options
  • Save claudiosanchez/d82f5b0440c2eaf0e0c3d97d7373653b to your computer and use it in GitHub Desktop.
Save claudiosanchez/d82f5b0440c2eaf0e0c3d97d7373653b to your computer and use it in GitHub Desktop.
// Our ViewModel will check very early on if it should show the Spending Analysis Widget or not.
public override void OnAppearing()
{
ShowSpendingAnalysis = _featureFlagService.Can(Features.CanSeeSpendingAnalysis);
}
...
// This method lives in a FeatureFlagService implementation. Remember to always keep your ViewModels clean!
public bool Can(string id)
{
if (_client == null) Initialize();
var results = _client.BoolVariation(id);
// Logging would be good
Console.WriteLine($"Feature {id} is {results} for user {_user.Name} ({_user.Key})");
return results;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment