Skip to content

[WIP]feat(deriv_feature_flag): Add features getter method to feature flag repository file #811

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:deriv_feature_flag/feature_flag/feature_flag_config.dart';
import 'package:deriv_feature_flag/feature_flag/feature_flag_repository.dart';
import 'package:deriv_feature_flag/growthbook/deriv_growth_book.dart';
import 'package:flutter/material.dart';
import 'package:growthbook_sdk_flutter/growthbook_sdk_flutter.dart';

class DerivFeatureFlag {
/// Initializes the FeatureFlag service for the whole app.
Expand All @@ -17,6 +18,12 @@ class DerivFeatureFlag {
.setup(derivGrowthBook: derivGrowthBook);
}

Map<String, dynamic> features() {
return FeatureFlagRepository.getInstance().features.map((key, value) {
return MapEntry(key, value.defaultValue);
});
}

/// Only for testing purposes.
@visibleForTesting
static Future<void> initializeTest(DerivGrowthBook derivGrowthBook) async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ class FeatureFlagRepository {
// Growth Book SDK instance.
late final GrowthBookSDK _growthBookSDK;

Map<String, GBFeature> _features = {};

Map<String, GBFeature> get features => _features;

/// initialize the GrowthBook sdk instance.
Future<void> setup({required DerivGrowthBook derivGrowthBook}) async {
_growthBookSDK = await derivGrowthBook.initializeSDK();
_features = _growthBookSDK.features;
}

/// get the feature flags value from the sdk.
Expand Down
Loading