File tree 3 files changed +26
-1
lines changed
Tests/Fluxor.UnitTests/ActionSubscriberTests
3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 1
1
# Releases
2
2
3
+ ### New in 3.7
4
+ * Fix for ([ #84 ] ( https://github.com/mrpmorris/Fluxor/issues/84 ) -
5
+ Allow observer to unsubscribe from all subscriptions whilst executing
6
+ the callback from a previous subscription
7
+
3
8
### New in 3.6
4
9
* Ensure synchronous effects are executed synchronously ([ #76 ] ( https://github.com/mrpmorris/fluxor/issues/76 ) ) -
5
10
Reverts changes for [ (#74 ) Endless loop redirects] ( https://github.com/mrpmorris/Fluxor/issues/74 ) as
Original file line number Diff line number Diff line change @@ -34,7 +34,8 @@ public void Notify(object action)
34
34
SubscriptionsForType
35
35
. Where ( x => x . Key . IsAssignableFrom ( action . GetType ( ) ) )
36
36
. SelectMany ( x => x . Value )
37
- . Select ( x => x . Callback ) ;
37
+ . Select ( x => x . Callback )
38
+ . ToArray ( ) ;
38
39
foreach ( Action < object > callback in callbacks )
39
40
callback ( action ) ;
40
41
} ) ;
Original file line number Diff line number Diff line change @@ -38,5 +38,24 @@ public void WhenExecuted_ThenOnlyUnsubscribesTheSpecifiedSubscriber()
38
38
Assert . Null ( actionReceivedBySubscriber1 ) ;
39
39
Assert . Same ( dispatchedAction , actionReceivedBySubscriber2 ) ;
40
40
}
41
+
42
+ [ Fact ]
43
+ public void WhenExecutedFromSubscriptionCallback_ThenDoesNotThrowAnError ( )
44
+ {
45
+ int executionCount = 0 ;
46
+ var subscriber = new object ( ) ;
47
+ var dispatchedAction = new TestAction ( ) ;
48
+
49
+ Subject . SubscribeToAction < TestAction > ( subscriber , x =>
50
+ {
51
+ executionCount ++ ;
52
+ Subject . UnsubscribeFromAllActions ( subscriber ) ;
53
+ } ) ;
54
+
55
+ Subject . Dispatch ( dispatchedAction ) ;
56
+ Subject . Dispatch ( dispatchedAction ) ;
57
+
58
+ Assert . Equal ( 1 , executionCount ) ;
59
+ }
41
60
}
42
61
}
You can’t perform that action at this time.
0 commit comments