ReplaySubject
public class ReplaySubject<Element>
: Observable<Element>
, SubjectType
, ObserverType
, Disposable
Represents an object that is both an observable sequence as well as an observer.
Each notification is broadcasted to all subscribed and future observers, subject to buffer trimming policies.
-
Undocumented
Declaration
Swift
public typealias SubjectObserverType = ReplaySubject<Element>
-
Indicates whether the subject has any observers
Declaration
Swift
public var hasObservers: Bool { get }
-
Notifies all subscribed observers about next event.
Declaration
Swift
public func on(_ event: Event<Element>)
Parameters
event
Event to send to the observers.
-
Returns observer interface for subject.
Declaration
Swift
public func asObserver() -> ReplaySubject<Element>
-
Unsubscribe all observers and release resources.
Declaration
Swift
public func dispose()
-
Creates new instance of
ReplaySubject
that replays at mostbufferSize
last elements of sequence.Declaration
Swift
public static func create(bufferSize: Int) -> ReplaySubject<Element>
Parameters
bufferSize
Maximal number of elements to replay to observer after subscription.
Return Value
New instance of replay subject.
-
Creates a new instance of
ReplaySubject
that buffers all the elements of a sequence. To avoid filling up memory, developer needs to make sure that the use case will only ever store a ‘reasonable’ number of elements.Declaration
Swift
public static func createUnbounded() -> ReplaySubject<Element>