Features Provider
Preparation
App features are available only with advanced Magify SDK integration.
Overview
Properties
OnFeaturesUpdated
event Action OnFeaturesUpdated
The event is triggered every time a features list or values are updated.
IsCurrentFeaturesParsed
bool IsCurrentFeaturesParsed { get; }
The field returns true if there is an actual config (the one that was downloaded from the backend) and that was successfully parsed.
StoredAppFeatures
IStoredAppFeaturesCollection StoredAppFeatures { get; }
Returns read-only reactive collection of current stored app features.
StoredAppFeaturesLoadingTimeoutSeconds
NumberRemoteProperty StoredAppFeaturesLoadingTimeoutSeconds { get; }
Uses MagifySettings.StoredAppFeaturesLoadingTimeoutSeconds to set timeout for loading of each stored app feature.
Stored app features
LoadStoredAppFeature
UniTask<ContentHandle<StoredAppFeatureContent>> LoadStoredAppFeature(StoredAppFeature feature, CancellationToken cancellationToken, double? timeoutSeconds = null);
UniTask<ContentHandle<StoredAppFeatureContent>> LoadStoredAppFeature([NotNull] string featureName, CancellationToken cancellationToken, double? timeoutSeconds = null);
Requests to download the feature content. Firstly a web request is sent to check if we already have the actual content value on disk. If there is, it will be loaded from disk, otherwise the content will be downloaded and saved for later use.
Returns: Content Handle: The content will remain in the cache as long as there is at least one handle that has not been disposed of. Remember to dispose of it when you want to release content from RAM if you don't want a memory leak.
LoadStoredAppFeatures
UniTask<IEnumerable<ContentHandle<StoredAppFeatureContent>>> LoadStoredAppFeatures([NotNull] IEnumerable<StoredAppFeature> features, CancellationToken cancellationToken, double? timeoutSeconds = null);
UniTask<IEnumerable<ContentHandle<StoredAppFeatureContent>>> LoadStoredAppFeatures([NotNull, ItemNotNull] IEnumerable<string> features, CancellationToken cancellationToken, double? timeoutSeconds = null);
UniTask<IEnumerable<ContentHandle<StoredAppFeatureContent>>> LoadStoredAppFeatures(CancellationToken cancellationToken, double? timeoutSeconds = null);
The same as LoadStoredAppFeature, but for many features: Requests to download the feature content. Firstly a web request is sent to check if we already have the actual content value on disk. If there is, it will be loaded from disk, otherwise the content will be downloaded and saved for later use.
Boolean
TryGetBool
bool TryGetBool(string featureName, out bool result)
The method will return true
if it was possible to get a bool
value for featureName
, the obtained value will be put into result, otherwise the method will return false
.
GetBool
bool GetBool(string featureName)
The method will return a bool
value for featureName
, if the value cannot be received an ArgumentException
will be thrown.
GetReactiveBool
IReadOnlyReactiveProperty<bool> GetReactiveBool(string featureName, bool defaultValue = default)
The method will return a bool
reactive field for featureName
, initializing it with defaultValue
in case Magify does not yet have a value for the specified feature. The field will be updated together with the call of the OnFeaturesUpdated event.
Numbers
TryGetNumber
bool TryGetNumber(string featureName, out double result)
The method will return true
if it was possible to get a double
value for featureName
, the obtained value will be put into result, otherwise the method will return false
.
GetNumber
double GetNumber(string featureName)
The method will return a double
value for featureName
, if the value cannot be received an ArgumentException
will be thrown.
GetReactiveNumber
IReadOnlyReactiveProperty<double> GetReactiveNumber(string featureName, double defaultValue = default)
The method will return a double
reactive field for featureName
, initializing it with defaultValue
in case Magify does not yet have a value for the specified feature. The field will be updated together with the call of the OnFeaturesUpdated event.
Strings
TryGetString
bool TryGetString(string featureName, out string result)
The method will return true
if it was possible to get a string
value for featureName
, the obtained value will be put into result, otherwise the method will return false
.
GetString
string GetString(string featureName)
The method will return a string
value for featureName
, if the value cannot be received an ArgumentException
will be thrown.
GetReactiveString
IReadOnlyReactiveProperty<string> GetReactiveString(string featureName, string defaultValue = default)
The method will return a string
reactive field for featureName
, initializing it with defaultValue
in case Magify does not yet have a value for the specified feature. The field will be updated together with the call of the OnFeaturesUpdated event.