Documentation ¶
Index ¶
- Constants
- Variables
- func IsCancelledError(err error) bool
- func NewContextError(err error) error
- type Any
- type Disposable
- type FnOnCancel
- type FnOnComplete
- type FnOnDiscard
- type FnOnError
- type FnOnFinally
- type FnOnNext
- type FnOnRequest
- type FnOnSubscribe
- type Item
- type Predicate
- type Processor
- type Publisher
- type RawPublisher
- type SignalType
- type Subscriber
- type SubscriberOption
- type Subscription
- type Transformer
Constants ¶
const RequestInfinite = math.MaxInt32
RequestInfinite means request items indefinitely.
Variables ¶
var ( ErrNegativeRequest = fmt.Errorf("invalid request: n must be between %d and %d", 1, RequestInfinite) ErrSubscribeCancelled = errors.New("subscriber has been cancelled") )
Functions ¶
func IsCancelledError ¶ added in v0.2.4
IsCancelledError returns true if given error is a cancelled subscribe error.
func NewContextError ¶ added in v0.4.2
Types ¶
type Any ¶ added in v0.2.0
type Any = interface{}
Any is an alias of interface{} which means a value of any type.
type Disposable ¶
type Disposable interface {
// Dispose dispose current resource.
Dispose()
}
Disposable is a disposable resource.
type FnOnSubscribe ¶
type FnOnSubscribe = func(ctx context.Context, su Subscription)
A group of action functions.
type Processor ¶
type Processor interface { Publisher Subscriber }
Processor combines the Publisher and Subscriber.
type Publisher ¶
type Publisher interface { RawPublisher // Subscribe subscribes current Publisher with some options. Subscribe(context.Context, ...SubscriberOption) }
Publisher is th basic type that can be subscribed
type RawPublisher ¶ added in v0.0.2
type RawPublisher interface { // SubscribeWith subscribes current Publisher with a Subscriber. SubscribeWith(context.Context, Subscriber) }
RawPublisher is the basic low-level Publisher that can be subscribed with a Subscriber.
type SignalType ¶ added in v0.0.5
type SignalType int8
SignalType is type of terminal signal.
const ( SignalTypeDefault SignalType = iota SignalTypeComplete SignalTypeCancel SignalTypeError )
func (SignalType) String ¶ added in v0.0.5
func (s SignalType) String() string
type Subscriber ¶
type Subscriber interface { // OnComplete is successful terminal state. OnComplete() // OnError is failed terminal state. OnError(error) // OnNext is invoked when a data notification sent by the Publisher in response to requests to Subscription.Request(int). OnNext(Any) // OnSubscribe is invoked after calling RawPublisher.SubscribeWith(context.Context, Subscriber). OnSubscribe(context.Context, Subscription) }
Subscriber is the basic type to subscribing the Publisher and consumes the items from upstream.
func NewSubscriber ¶
func NewSubscriber(opts ...SubscriberOption) Subscriber
NewSubscriber creates a Subscriber with given options.
type SubscriberOption ¶
type SubscriberOption func(*subscriber)
SubscriberOption is used to create a Subscriber easily.
func OnComplete ¶
func OnComplete(onComplete FnOnComplete) SubscriberOption
OnComplete specified a Subscriber.OnComplete action.
func OnError ¶
func OnError(onError FnOnError) SubscriberOption
OnError specified a Subscriber.OnError action.
func OnNext ¶
func OnNext(onNext FnOnNext) SubscriberOption
OnNext specified a Subscriber.OnNext action.
func OnSubscribe ¶
func OnSubscribe(onSubscribe FnOnSubscribe) SubscriberOption
OnSubscribe specified a Subscriber.OnSubscribe action.
type Subscription ¶
type Subscription interface { // Request requests the next N items. Request(n int) // Cancel cancels the current lifecycle of subscribing. Cancel() }
Subscription represents a one-to-one lifecycle of a Subscriber subscribing to a Publisher.