Skip to content

Commit 3896d92

Browse files
committed
Send the latest non-null theme directly to the new action
1 parent e8c9772 commit 3896d92

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

org.mixedrealitytoolkit.theming/Theming/ThemeDataSource.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public Theme value
3838
// element, but ChangeEvent<T> is used for its newValue/previousValue semantics
3939
// and object pooling
4040
SetValueWithoutNotify(value);
41-
SendEvent(changeEvent);
41+
onThemeChanged.Invoke(changeEvent);
4242
}
4343
}
4444
}
@@ -53,22 +53,17 @@ public void SetValueWithoutNotify(Theme newValue)
5353

5454
public void AddListener(UnityAction<ChangeEvent<Theme>> action)
5555
{
56+
if (action == null) { return; }
5657
onThemeChanged.AddListener(action);
58+
if (activeTheme == null) { return; }
5759
using ChangeEvent<Theme> changeEvent = ChangeEvent<Theme>.GetPooled(null, activeTheme);
58-
SendEvent(changeEvent);
60+
action.Invoke(changeEvent);
5961
}
6062

6163
public void RemoveListener(UnityAction<ChangeEvent<Theme>> action)
6264
{
65+
if (action == null) { return; }
6366
onThemeChanged.RemoveListener(action);
6467
}
65-
66-
private void SendEvent(EventBase e)
67-
{
68-
if (e is ChangeEvent<Theme> changeEvent)
69-
{
70-
onThemeChanged.Invoke(changeEvent);
71-
}
72-
}
7368
}
7469
}

0 commit comments

Comments
 (0)