feature(feedbacks): adds public property AlwaysSendValue and new constructor to Bool, Int, and String Feedbacks that will always perform a FireUpdate event even when value is the same.

This commit is contained in:
Jason Alborough
2021-07-25 11:52:10 -04:00
parent 10f5516a5a
commit e3f5d74e7e
3 changed files with 23 additions and 4 deletions

View File

@@ -18,6 +18,7 @@ namespace PepperDash.Essentials.Core
/// </summary>
public override bool BoolValue { get { return _BoolValue; } }
bool _BoolValue;
public bool AlwaysSendValue;
/// <summary>
/// Fake value to be used in test mode
@@ -62,10 +63,16 @@ namespace PepperDash.Essentials.Core
ValueFunc = valueFunc;
}
public BoolFeedback(string key, bool alwaysSendValue, Func<bool> valueFunc)
: this(key, valueFunc)
{
AlwaysSendValue = alwaysSendValue;
}
public override void FireUpdate()
{
bool newValue = InTestMode ? TestValue : ValueFunc.Invoke();
if (newValue != _BoolValue)
if (newValue != _BoolValue || AlwaysSendValue)
{
_BoolValue = newValue;
LinkedInputSigs.ForEach(s => UpdateSig(s));