-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
85 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
namespace R3 | ||
{ | ||
public static partial class EventFactory | ||
{ | ||
// Never | ||
public static Event<T> Never<T>() | ||
{ | ||
return R3.Factories.Never<T>.Instance; | ||
} | ||
|
||
// NeverComplete | ||
public static CompletableEvent<TMessage, TComplete> NeverComplete<TMessage, TComplete>() | ||
{ | ||
return R3.Factories.NeverComplete<TMessage, TComplete>.Instance; | ||
} | ||
} | ||
} | ||
|
||
namespace R3.Factories | ||
{ | ||
// Never | ||
internal sealed class Never<T> : Event<T> | ||
{ | ||
// singleton | ||
public static readonly Never<T> Instance = new Never<T>(); | ||
|
||
Never() | ||
{ | ||
|
||
} | ||
|
||
protected override IDisposable SubscribeCore(Subscriber<T> subscriber) | ||
{ | ||
return Disposable.Empty; | ||
} | ||
} | ||
|
||
|
||
// NeverComplete | ||
internal sealed class NeverComplete<TMessage, TComplete> : CompletableEvent<TMessage, TComplete> | ||
{ | ||
// singleton | ||
public static readonly NeverComplete<TMessage, TComplete> Instance = new NeverComplete<TMessage, TComplete>(); | ||
|
||
NeverComplete() | ||
{ | ||
|
||
} | ||
|
||
protected override IDisposable SubscribeCore(Subscriber<TMessage, TComplete> subscriber) | ||
{ | ||
return Disposable.Empty; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace R3.Tests.FactoryTests; | ||
|
||
public class NeverTest | ||
{ | ||
[Fact] | ||
public void Never() | ||
{ | ||
using var list = EventFactory.Never<int>().LiveRecord(); | ||
list.AssertIsNotCompleted(); | ||
} | ||
|
||
// NeverComplete test | ||
[Fact] | ||
public void NeverComplete() | ||
{ | ||
using var list = EventFactory.NeverComplete<int, int>().LiveRecord(); | ||
list.AssertIsNotCompleted(); | ||
} | ||
} |