MCPcopy Create free account
hub / github.com/ReactiveX/RxGo / DefaultIfEmpty

Method DefaultIfEmpty

observable_operator.go:710–717  ·  view source on GitHub ↗

DefaultIfEmpty returns an Observable that emits the items emitted by the source Observable or a specified default item if the source Observable is empty.

(defaultValue interface{}, opts ...Option)

Source from the content-addressed store, hash-verified

708// DefaultIfEmpty returns an Observable that emits the items emitted by the source
709// Observable or a specified default item if the source Observable is empty.
710func (o *ObservableImpl) DefaultIfEmpty(defaultValue interface{}, opts ...Option) Observable {
711 return observable(o.parent, o, func() operator {
712 return &defaultIfEmptyOperator{
713 defaultValue: defaultValue,
714 empty: true,
715 }
716 }, true, false, opts...)
717}
718
719type defaultIfEmptyOperator struct {
720 defaultValue interface{}

Callers

nothing calls this directly

Calls 1

observableFunction · 0.85

Tested by

no test coverage detected