Skip to content

Commit 4e37d31

Browse files
authored
Handle partial creation of DisposableAction (fixes #29) (#30)
* Handle partial creation
1 parent 9f3007a commit 4e37d31

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Docs/releases.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Ensured add/remove on events are thread safe ([#23](https://github.com/mrpmorris/Fluxor/issues/23))
66
* Made it easier to find the source of DisposableCallback instances that are not disposed ([#24](https://github.com/mrpmorris/Fluxor/issues/24))
77
* State properties were not discovered if they were declared as private in a base class ([#25](https://github.com/mrpmorris/Fluxor/issues/25))
8+
* Handle disposing of partially created DisposableAction ([#29](https://github.com/mrpmorris/Fluxor/issues/29))
89

910
### New in 3.1.0
1011
* Used Newtonsoft entirely for JS interop to ReduxDevTools to prevent serialization errors ([#7](https://github.com/mrpmorris/Fluxor/issues/7))

Source/Fluxor/DisposableCallback.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public sealed class DisposableCallback : IDisposable
1212
private readonly string Id;
1313
private readonly Action Action;
1414
private bool IsDisposed;
15+
private bool WasCreated;
1516

1617
/// <summary>
1718
/// Creates an instance of the class
@@ -30,6 +31,7 @@ public DisposableCallback(string id, Action action)
3031

3132
Id = id;
3233
Action = action;
34+
WasCreated = true;
3335
}
3436

3537
/// <summary>
@@ -53,7 +55,7 @@ public void Dispose()
5355
/// <exception cref="InvalidOperationException">Thrown if the object is collected without being disposed</exception>
5456
~DisposableCallback()
5557
{
56-
if (!IsDisposed)
58+
if (!IsDisposed && WasCreated)
5759
throw new InvalidOperationException($"{nameof(DisposableCallback)} with Id \"{Id}\" was not disposed.");
5860
}
5961
}

0 commit comments

Comments
 (0)