-
-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from Cysharp/select-await
Add SelectAwait, WhereAwait, SubscribeAwait
- Loading branch information
Showing
18 changed files
with
1,388 additions
and
130 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
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 |
---|---|---|
@@ -1,97 +1,22 @@ | ||
using R3; | ||
using System.ComponentModel.DataAnnotations; | ||
using System.Reactive.Linq; | ||
|
||
|
||
Console.WriteLine("hello"); | ||
// System.Linq.AsyncEnumerable.Range(1,10) | ||
|
||
//Dump.Factory(); | ||
|
||
var hoge = new Hoge(); | ||
|
||
hoge.MyProperty1.ErrorsChanged += MyProperty1_ErrorsChanged; | ||
hoge.MyProperty2.ErrorsChanged += MyProperty2_ErrorsChanged; | ||
|
||
void MyProperty1_ErrorsChanged(object? sender, System.ComponentModel.DataErrorsChangedEventArgs e) | ||
{ | ||
foreach (var item in hoge.MyProperty1.GetErrors(null!)) | ||
{ | ||
Console.WriteLine(item); | ||
} | ||
} | ||
void MyProperty2_ErrorsChanged(object? sender, System.ComponentModel.DataErrorsChangedEventArgs e) | ||
{ | ||
foreach (var item in hoge.MyProperty2.GetErrors(null!)) | ||
{ | ||
Console.WriteLine(item); | ||
} | ||
} | ||
hoge.MyProperty1.Value = 30; | ||
hoge.MyProperty2.Value = 40; | ||
|
||
|
||
//ObservableTracker.EnableTracking = true; | ||
//ObservableTracker.EnableStackTrace = true; | ||
|
||
//using var factory = LoggerFactory.Create(x => | ||
//{ | ||
// x.SetMinimumLevel(LogLevel.Trace); | ||
// x.AddZLoggerConsole(); | ||
//}); | ||
//// ObservableSystem.Logger = factory.CreateLogger<ObservableSystem>(); | ||
//var logger = factory.CreateLogger<Program>(); | ||
|
||
|
||
|
||
|
||
//var sw = Stopwatch.StartNew(); | ||
//var subject1 = new System.Reactive.Subjects.Subject<int>(); | ||
//var subject2 = new System.Reactive.Subjects.Subject<int>(); | ||
////subject1.WithLatestFrom(subject2.Finally(() => Console.WriteLine("finally subject2")), (x, y) => (x, y)).Subscribe(x => Console.WriteLine(x), () => Console.WriteLine("end")); | ||
|
||
//subject1.Scan((x, y) => x + y).Subscribe(x => Console.WriteLine(x), () => Console.WriteLine("end")); | ||
|
||
|
||
//subject1.OnNext(1); | ||
//subject1.OnNext(10); | ||
////subject1.OnNext(10); | ||
////subject1.OnNext(100); | ||
|
||
//// subject1.SequenceEqual( | ||
|
||
|
||
//// System.Reactive.Linq.Observable.Switch( | ||
|
||
//Dump.Factory(); | ||
|
||
//public static class Extensions | ||
//{ | ||
// public static IDisposable WriteLine<T>(this Observable<T> source) | ||
// { | ||
// return source.Subscribe(x => Console.WriteLine(x), x => Console.WriteLine(x)); | ||
// } | ||
//} | ||
//System.Reactive.Linq.Observable.Range(1,10).SelectMany( | ||
|
||
//var onClick = new Subject<Unit>(); | ||
//var httpClient = new HttpClient(); | ||
|
||
|
||
//class TestDisposable : IDisposable | ||
//onClick.SelectAwait(async x => | ||
//{ | ||
// public int CalledCount = 0; | ||
|
||
// public void Dispose() | ||
// { | ||
// CalledCount += 1; | ||
// } | ||
//} | ||
|
||
|
||
public class Hoge | ||
{ | ||
[Range(1, 10)] | ||
public BindableReactiveProperty<int> MyProperty1 { get; set; } = new BindableReactiveProperty<int>().EnableValidation<Hoge>(); | ||
|
||
[Range(1, 10)] | ||
public BindableReactiveProperty<int> MyProperty2 { get; set; } | ||
|
||
public Hoge() | ||
{ | ||
MyProperty2 = new BindableReactiveProperty<int>().EnableValidation(() => MyProperty2); | ||
} | ||
} | ||
//}); |
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
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,8 @@ | ||
namespace R3; | ||
|
||
public enum AwaitOperations | ||
{ | ||
Queue, | ||
Drop, | ||
Parallel | ||
} |
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,18 @@ | ||
using System.Threading.Channels; | ||
|
||
namespace R3.Internal; | ||
|
||
internal static class ChannelUtility | ||
{ | ||
static readonly UnboundedChannelOptions options = new UnboundedChannelOptions | ||
{ | ||
SingleWriter = true, // in Rx operator, OnNext gurantees synchronous | ||
SingleReader = true, // almostly uses single reader loop | ||
AllowSynchronousContinuations = true // if false, uses TaskCreationOptions.RunContinuationsAsynchronously so avoid it. | ||
}; | ||
|
||
internal static Channel<T> CreateSingleReadeWriterUnbounded<T>() | ||
{ | ||
return Channel.CreateUnbounded<T>(options); | ||
} | ||
} |
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
Oops, something went wrong.