示例#1
0
 public void SetInputStream(IEmptyStream stream)
 {
     if (inputStreamConnection != null)
     {
         inputStreamConnection.Dispose();
     }
     inputStreamConnection = stream.Listen(() => Send());
 }
示例#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;
     }));
 }
示例#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;
     }));
 }
示例#4
0
 public static IEmptyStream Where(this IEmptyStream stream, Func <bool> o)
 {
     return(new AnonymousEmptyStream((Action reaction, Priority p) =>
     {
         return stream.Listen(() =>
         {
             if (o())
             {
                 reaction();
             }
         }, p);
     }));
 }
示例#5
0
    public static IEmptyStream MergeWith(this IEmptyStream stream, params IEmptyStream[] others)
    {
        return(new AnonymousEmptyStream((reaction, p) =>
        {
            ListDisposable disp = new ListDisposable();
            disp.Add(stream.Listen(reaction, p));

            foreach (var other in others)
            {
                disp.Add(other.Listen(reaction, p));
            }

            return disp;
        }));
    }
示例#6
0
 public static IDisposable LateListen(this IEmptyStream stream, Action action)
 {
     return(stream.Listen(action, Priority.Post));
 }