You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -110,7 +110,15 @@ public final class ForEachPublisher<O>: IteratorPublisherClassBase<O> {
110
110
}
111
111
}
112
112
113
-
// MARK: `Subscribers`s.
113
+
// MARK: `Subscriber`s.
114
+
115
+
/// Signals, as opossed to errors, that `Subscriber`s can send by throwing the signals as errors (they are intercepted and do not result in stream errors).
116
+
/// There is no standard way of a subscriber asking for actions, e.g. completion, in the Reactive Stream Specification and therefore throwing these signals must only be used within the Reactive Collection Library.
117
+
publicenumSubscriberSignal:Error{
118
+
/// Indicates that the subscribers input subscription should be cancelled and the subscriber's `onComplete` method should be called to mark the end of items from the subscription.
119
+
/// This is useful when a subscriber, or a processor which is a subscriber, needs to signal successful completion, rather than signal an error.
120
+
case cancelInputSubscriptionAndComplete
121
+
}
114
122
115
123
/// A `Subscriber` that is also a `Future` that takes items from its subscription and passes them to the given `updateAccumulatingResult` which combines them with the given `initialResult` and when finished returns via `get` the now modified `initialResult` (Reactive Stream version of `Sequence.reduce(into:_:)`).
116
124
///
@@ -128,7 +136,7 @@ public final class ForEachPublisher<O>: IteratorPublisherClassBase<O> {
/// A `Subscriber` that is also a future that takes items from its subscription and passes them to the given `updateAccumulatingResult` which combines them with the given `initialResult` and when finished returns via `get` the now modified `initialResult` (Reactive Stream version of `Sequence.reduce(into:_:)`).
@@ -150,14 +158,14 @@ public final class ReduceSubscriberFuture<T, R>: SubscriberFutureClassBase<T, R>
150
158
/// - updateAccumulatingResult: A closure that accepts the given `into` as an `inout` parameter and an item from a subscription and combines them into `into`.
151
159
/// - accumulator: The running accumulator (this is the given `into` and is the value returned via `get`).
152
160
/// - next: The next item to be accumulated.
153
-
publicinit(timeout:DispatchTimeInterval=Futures.defaultTimeout, bufferSize:Int=ReactiveStreams.defaultBufferSize, into initialResult:R, updateAccumulatingResult:@escaping(_ accumulator:inoutR, _ next:T)throws->()){
161
+
publicinit(timeout:DispatchTimeInterval=Futures.defaultTimeout, bufferSize:Int=ReactiveStreams.defaultBufferSize, into initialResult:R, updateAccumulatingResult:@escaping(_ accumulator:inoutR, _ next:T)throws->()){
@@ -175,3 +183,47 @@ public final class ReduceSubscriberFuture<T, R>: SubscriberFutureClassBase<T, R>
175
183
}
176
184
177
185
// MARK: `Processors`s.
186
+
187
+
/// A `Processor` that takes input items from its input subscription maps (a.k.a. processes, a.k.a. transforms) them into output items, using its seed, and outputs them and to its output subscriber (Reactive Stream version of `Sequence.map(_ transform:)`).
188
+
///
189
+
/// - warning:
190
+
/// - `processors`s are not thread safe, since they are an alternative to dealing with thread safety directly and therefore it makes no sense to share them between threads.
191
+
/// - There are *no* `Publisher` methods/properties intended for use by a client (the programmer using an instance of this class), the client *only* passes the instance to the `subscribe` method of a `Publisher`.
192
+
/// Passing the instance to the publisher is best accomplished using operator `~~>`, since this emphasizes that the other methods are not for client use.
193
+
///
194
+
/// - parameters
195
+
/// - S: The type of the seed accepted by the given transform closure.
196
+
/// - T: The type of the elements subscribed to.
197
+
/// - R: The result type of the accumulation.
198
+
publicfinalclassMapSeededProcessor<S, I, O>:MapProcessorClassBase<I,O>{
199
+
privateletinitialSeed:S
200
+
201
+
privatelettransformClosure:(inoutS,I)throws->O
202
+
203
+
privatevarseed:S
204
+
205
+
/// A `Processor` that takes input items from its input subscription maps (a.k.a. processes, a.k.a. transforms) them into output items, using its seed, and outputs them and to its output subscriber (Reactive Stream version of `Sequence.map(_ transform:)`).
206
+
///
207
+
/// - parameters:
208
+
/// - initialSeed: The initial value of the seed at the start of new input and output subscription.
209
+
/// - transform: The mapping/processing transform that converts an input item intop an output item.
0 commit comments