-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathISubscriber.cs
76 lines (72 loc) · 2.88 KB
/
ISubscriber.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using System;
namespace Reactive.Streams
{
/// <summary>
/// <para>
/// Will receive call to <see cref="OnSubscribe"/> once after passing an instance of
/// <see cref="ISubscriber{T}"/> to <see cref="IPublisher{T}.Subscribe"/>.
/// </para>
/// <para>
/// No further notifications will be received until <see cref="ISubscription.Request"/> is called.
/// </para>
/// <para>After signaling demand:</para>
/// <para>1. One or more invocations of <see cref="OnNext"/> up to the maximum number defined by
/// <see cref="ISubscription.Request"/></para>
/// <para>2. Single invocation of <see cref="OnError"/> or
/// <see cref="OnComplete"/> which signals a terminal state after which no further
/// events will be sent.</para>
/// <para>
/// Demand can be signaled via <see cref="ISubscription.Request"/> whenever the
/// <see cref="ISubscriber{T}"/> instance is capable of handling more.</para>
/// </summary>
/// <typeparam name="T">The type of element signaled.</typeparam>
public interface ISubscriber<in T>
{
/// <summary>
/// <para>
/// Invoked after calling <see cref="IPublisher{T}.Subscribe"/>.
/// </para>
/// <para>
/// No data will start flowing until <see cref="ISubscription.Request"/> is invoked.
/// </para>
/// <para>
/// It is the responsibility of this <see cref="ISubscriber{T}"/> instance to call
/// <see cref="ISubscription.Request"/> whenever more data is wanted.
/// </para>
/// <para>
/// The <see cref="IPublisher{T}"/> will send notifications only in response to
/// <see cref="ISubscription.Request"/>.
/// </para>
/// </summary>
/// <param name="subscription"><see cref="ISubscription"/> that allows requesting data
/// via <see cref="ISubscription.Request"/></param>
void OnSubscribe(ISubscription subscription);
/// <summary>
/// Data notification sent by the <see cref="IPublisher{T}"/> in response to requests to
/// <see cref="ISubscription.Request"/>.
/// </summary>
/// <param name="element">The element signaled</param>
void OnNext(T element);
/// <summary>
/// <para>
/// Failed terminal state.
/// </para>
/// <para>
/// No further events will be sent even if <see cref="ISubscription.Request"/> is
/// invoked again.
/// </para>
/// </summary>
/// <param name="cause">The exception signaled</param>
void OnError(Exception cause);
/// <summary>
/// <para>
/// Successful terminal state.
/// </para>
/// <para>
/// No further events will be sent even if <see cref="ISubscription.Request"/> is
/// invoked again.
/// </para>
/// </summary>
void OnComplete();
}
}