Target filter
Search Kotlin docs
  • Platforms
  • Tealium Prism Kotlin
core/com.tealium.prism.core.api.pubsub/Subject

Subject

interface Subject<T> : Observable<T> , Observer<T>

A Subject is an Observable that can be used to publish new values to any subscribers, where an Observable cannot.

New values can be emitted to subscribers via the Observer.onNext method.

Inheritors

ReplaySubject
StateSubject

Properties

count
Link copied to clipboard
abstract val count: Int

Returns the number of subscribers to this Subject

Functions

asObservable
Link copied to clipboard
abstract fun asObservable(): Observable<T>

Returns this Subject as an Observable to restrict publishing.

asSingle
Link copied to clipboard
open fun asSingle(scheduler: Scheduler): Single<T>

Converts this Observable to a Single subscribing on the given Scheduler

async
Link copied to clipboard
open fun <R> async(block: (T, Observer<R>) -> Disposable): Observable<R>

Returns an observable that will emit values in a possibly asynchronous manner determined by the given block.

buffered
Link copied to clipboard
open fun buffered(count: Int): Observable<T>

Returns an observable that will buffer emissions until the buffer is full, at which point they will be emitted downstream.

callback
Link copied to clipboard
open fun <R> callback(block: (T, Observer<R>) -> Unit): Observable<R>

Returns an observable that will emit values in a possibly asynchronous manner determined by the given block.

combine
Link copied to clipboard
open fun <T2, R> combine(other: Observable<T2>, combiner: (T, T2) -> R): Observable<R>

Returns an observable that combines the emissions of this observable the given other. The downstream emission is the result of applying the combiner function to the latest emissions of both observables - and are only possible once both this and the other have emitted at least one value.

open fun <T2, T3, R> combine(other1: Observable<T2>, other2: Observable<T3>, combiner: (T, T2, T3) -> R): Observable<R>

Returns an observable that combines the emissions of this observable the given others. The downstream emission is the result of applying the combiner function to the latest emissions of both observables - and are only possible once all others have emitted at least one value.

distinct
Link copied to clipboard
open fun distinct(): Observable<T>

Returns an observable that only emits downstream when the newest emissions is not equal to the previous emission. Emissions will be compared using standard Objects.equals

open fun distinct(isEquals: (T, T) -> Boolean): Observable<T>

Returns an observable that only emits downstream when the newest emissions is not equal to the previous emission. Emissions will be compared using the provided isEquals function

filter
Link copied to clipboard
open fun filter(predicate: (T) -> Boolean): Observable<T>

Returns an observable that filters out emissions that do not match the given predicate

filterNotNull
Link copied to clipboard
fun <T> Observable<T?>.filterNotNull(): Observable<T>

Convenience method for converting an observable of nullable items, into an observable of non-nullable items.

flatMap
Link copied to clipboard
open fun <R> flatMap(transform: (T) -> Observable<R>): Observable<R>

Returns an observable that applies the given transform to the source emissions to produce new observables - all emissions from the resulting observables will be emitted downstream.

flatMapLatest
Link copied to clipboard
open fun <R> flatMapLatest(transform: (T) -> Observable<R>): Observable<R>

Returns an observable that applies the given transform to the source emissions to produce a new observable - only emissions from the latest observable created by the transform will be emitted downstream.

forEach
Link copied to clipboard
open fun forEach(block: (T) -> Unit): Observable<T>

Returns an observable that will call the given block with each source emission, before passing the original emission downstream.

map
Link copied to clipboard
open fun <R> map(transform: (T) -> R): Observable<R>

Returns an observable that applies the given transform to each emission before passing it downstream.

mapNotNull
Link copied to clipboard
open fun <R> mapNotNull(transform: (T) -> R?): Observable<R>

Returns an observable that applies the given transform to each emission before passing it downstream. Only emissions that are non-null after the application of the transform will be emitted downstream.

mapToUnit
Link copied to clipboard
fun <T> Observable<T>.mapToUnit(): Observable<Unit>

Convenience method that maps any incoming emission to Unit

merge
Link copied to clipboard
open fun merge(other: Observable<T>): Observable<T>

Returns an observable that will propagate all source emissions downstream from this observable and from the given other.

observeOn
Link copied to clipboard
open fun observeOn(scheduler: Scheduler): Observable<T>

Returns an observable that propagates emissions downstream on the given scheduler

onNext
Link copied to clipboard
abstract fun onNext(value: T)

Called whenever there has been a new item emitted by the upstream Observable.

resubscribingWhile
Link copied to clipboard
open fun resubscribingWhile(predicate: (T) -> Boolean): Observable<T>

Returns an observable that will continually resubscribe until the predicate returns false.

share
Link copied to clipboard
open fun share(): Observable<T>
open fun share(replay: Int): Observable<T>

Returns an Observable that will share a single connection to the source Observable (this).

startWith
Link copied to clipboard
open fun startWith(vararg item: T): Observable<T>

Returns an observable that will emit all the given item values before making a subscription to the source observable.

subscribe
Link copied to clipboard
abstract fun subscribe(observer: Observer<T>): Disposable

Subscribes the given observer to receive updates

subscribeOn
Link copied to clipboard
open fun subscribeOn(scheduler: Scheduler): Observable<T>

Returns an observable that performs the subscription on the given scheduler

subscribeOnce
Link copied to clipboard
open fun subscribeOnce(observer: Observer<T>): Disposable

Subscribes the given observer to a single emission of the source.

take
Link copied to clipboard
open fun take(count: Int): Observable<T>

Returns an observable that emits only the specified number of events given by the provided count

takeWhile
Link copied to clipboard
open fun takeWhile(predicate: (T) -> Boolean): Observable<T>
open fun takeWhile(inclusive: Boolean, predicate: (T) -> Boolean): Observable<T>

Returns an observable that emits downstream up until the predicate returns false.

Generated by Dokka
(c) Tealium 2026