Skip to content

Commit

Permalink
DisconnectWhen implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
Federico Alterio authored and Federico Alterio committed Dec 20, 2024
1 parent 20ec264 commit 79f3839
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
21 changes: 8 additions & 13 deletions SignalsDotnet/SignalsDotnet/Helpers/ObservableEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,13 @@ public static class ObservableEx
{
public static Observable<T> DisconnectWhen<T>(this Observable<T> @this, Observable<bool> isDisconnected)
{
throw new InvalidOperationException();
//return isDisconnected.Prepend(true)
// .DistinctUntilChanged()
// .Replay(1)
// .AutoConnect(0)
// .Select(x => x switch
// {
// false => @this,
// true => Observable.Empty<T>()
// })
// .Switch()
// .Publish()
// .RefCount();
return isDisconnected.Select(x => x switch
{
false => @this,
true => Observable.Empty<T>()
})
.Switch()
.Publish()
.RefCount();
}
}
2 changes: 1 addition & 1 deletion SignalsDotnet/SignalsDotnet/SignalsDotnet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Description>Porting of Angular signals to dotnet</Description>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/fedeAlterio/SignalsDotnet</RepositoryUrl>
<Version>2.0.1-alpha</Version>
<Version>2.0.2-alpha</Version>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 79f3839

Please sign in to comment.