Exemple #1
0
 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;
     }));
 }
Exemple #2
0
 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;
     }));
 }
Exemple #3
0
 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;
     }));
 }
Exemple #4
0
    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;
        }));
    }