コード例 #1
0
ファイル: Stream.cs プロジェクト: AlexSergPosp/Test
 public static IStream <T> FirstOnly <T>(this IStream <T> stream)
 {
     return(new AnonymousStream <T>((Action <T> reaction, Priority p) =>
     {
         SingleAssignmentDisposable disp = new SingleAssignmentDisposable();
         disp.Disposable = stream.Listen(val =>
         {
             reaction(val);
             disp.Dispose();
         }, p);
         return disp;
     }));
 }
コード例 #2
0
ファイル: Stream.cs プロジェクト: AlexSergPosp/Test
 public static IEmptyStream FirstOnly(this IEmptyStream stream)
 {
     return(new AnonymousEmptyStream((Action reaction, Priority p) =>
     {
         SingleAssignmentDisposable disp = new SingleAssignmentDisposable();
         disp.Disposable = stream.Listen(() =>
         {
             reaction();
             disp.Dispose();
         }, p);
         return disp;
     }));
 }
コード例 #3
0
ファイル: Stream.cs プロジェクト: AlexSergPosp/Test
 private static IOnceEmptyStream OnceEmptyStream(IEmptyStream stream)
 {
     return(new AnonymousEmptyStream((Action reaction, Priority p) =>
     {
         SingleAssignmentDisposable disp = new SingleAssignmentDisposable();
         disp.Disposable = stream.Listen(() =>
         {
             reaction();
             disp.Dispose();
         }, p);
         return disp;
     }));
 }
コード例 #4
0
ファイル: Stream.cs プロジェクト: AlexSergPosp/Test
    static public IStream <T> Join <T>(this IStream <IStream <T> > stream)
    {
        return(new AnonymousStream <T>((Action <T> reaction, Priority p) =>
        {
            SingleAssignmentDisposable mainDisposable = new SingleAssignmentDisposable();
            SingleAssignmentDisposable inner = new SingleAssignmentDisposable();
            ListDisposable group = new ListDisposable {
                mainDisposable, inner
            };

            mainDisposable.Disposable = stream.Listen((IStream <T> innerStream) =>
            {
                var newDisp = innerStream.Listen(val =>
                {
                    reaction(val);
                }, p);
                inner.Dispose();
                inner.Disposable = newDisp;
            }, p);

            return group;
        }));
    }