Skip to content

Commit 1c0f3d7

Browse files
authored
Add CleanupSubscription method for better code organization
Refactor subscription cleanup into a separate method.
1 parent e0552f9 commit 1c0f3d7

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

StabilityMatrix.Avalonia/Controls/FADownloadableComboBox.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
2828
{
2929
base.OnApplyTemplate(e);
3030

31+
CleanupSubscription();
3132
DropDownOpened -= OnDropDownOpenedHandler;
3233
DropDownClosed -= OnDropDownClosedHandler;
3334

@@ -40,8 +41,7 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
4041

4142
private void OnDropDownOpenedHandler(object? sender, EventArgs e)
4243
{
43-
openSubscription?.Dispose();
44-
openSubscription = null;
44+
CleanupSubscription();
4545

4646
if (dropDownPopup?.Child is not Control popupChild)
4747
return;
@@ -64,6 +64,11 @@ private void OnDropDownOpenedHandler(object? sender, EventArgs e)
6464
}
6565

6666
private void OnDropDownClosedHandler(object? sender, EventArgs e)
67+
{
68+
CleanupSubscription();
69+
}
70+
71+
private void CleanupSubscription()
6772
{
6873
openSubscription?.Dispose();
6974
openSubscription = null;

0 commit comments

Comments
 (0)