initialize method
Future<void>
initialize(
- BuildContext context, {
- IFastErrorReporter? errorReporter,
})
override
Implementation
@override
Future<void> initialize(
BuildContext context, {
IFastErrorReporter? errorReporter,
}) async {
_logger.debug('Initializing...');
final bloc = FastFirebaseRemoteConfigBloc.instance;
var customConfig = defaultConfig;
if (customConfig == null) {
_logger.debug('Loading default config...');
final defaultConfigData = await _loadDefaultConfig(defaultConfigPath);
if (defaultConfigData != null) {
_logger.debug('Parsing default config...');
customConfig = await compute(parseDefaultConfig, defaultConfigData);
}
}
_logger.debug('Loaded default config: $customConfig');
bloc.addEvent(FastFirebaseRemoteConfigBlocEvent.init(
defaultConfig: customConfig,
));
final response = await RaceStream([
bloc.onError,
bloc.onData.where((FastFirebaseRemoteConfigBlocState state) {
return state.isInitialized;
}),
]).first;
if (response is! FastFirebaseRemoteConfigBlocState) {
_logger.error('Failed to initialize: $response');
throw response;
}
_logger.debug('Initialized');
}