Documentation
¶
Overview ¶
CombineLatestWith will subscribe to its Observable and all other Observables passed in. It will then wait for all of the Observables to emit before emitting the first slice. Whenever any of the subscribed observables emits, a new slice will be emitted containing all the latest value.
Example (CombineLatestWith) ¶
A := From(1, 4, 7)
B := From("two", "five", "eight")
C := From(3, 6, 9)
A.CombineLatestWith(B, C).Println()
Output: [1 two 3] [4 two 3] [4 five 3] [4 five 6] [7 five 6] [7 eight 6] [7 eight 9]
Index ¶
Examples ¶
Constants ¶
const ErrUnsubscribed = RxError("subscriber unsubscribed")
Unsubscribed is the error returned by wait when the Unsubscribe method is called on the subscription.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Observable ¶
type Observable func(Observer, Scheduler, Subscriber)
Observable is a function taking an Observer, Scheduler and Subscriber. Calling it will subscribe the Observer to events from the Observable.
func From ¶
func From(slice ...interface{}) Observable
From creates an Observable from multiple interface{} values passed in.
func (Observable) CombineLatestWith ¶
func (o Observable) CombineLatestWith(other ...Observable) ObservableSlice
CombineLatestWith will subscribe to its Observable and all other Observables passed in. It will then wait for all of the ObservableBars to emit before emitting the first slice. Whenever any of the subscribed observables emits, a new slice will be emitted containing all the latest value.
type ObservableObservable ¶
type ObservableObservable func(ObservableObserver, Scheduler, Subscriber)
ObservableObservable is a function taking an Observer, Scheduler and Subscriber. Calling it will subscribe the Observer to events from the Observable.
func FromObservable ¶
func FromObservable(slice ...Observable) ObservableObservable
FromObservable creates an ObservableObservable from multiple Observable values passed in.
func (ObservableObservable) CombineLatestAll ¶
func (o ObservableObservable) CombineLatestAll() ObservableSlice
CombineLatestAll flattens a higher order observable (e.g. ObservableObservable) by subscribing to all emitted observables (ie. Observable entries) until the source completes. It will then wait for all of the subscribed Observables to emit before emitting the first slice. Whenever any of the subscribed observables emits, a new slice will be emitted containing all the latest value.
type ObservableObserver ¶
type ObservableObserver func(next Observable, err error, done bool)
ObservableObserver is a function that gets called whenever the Observable has something to report. The next argument is the item value that is only valid when the done argument is false. When done is true and the err argument is not nil, then the Observable has terminated with an error. When done is true and the err argument is nil, then the Observable has completed normally.
type ObservableSlice ¶
type ObservableSlice func(SliceObserver, Scheduler, Subscriber)
ObservableSlice is a function taking an Observer, Scheduler and Subscriber. Calling it will subscribe the Observer to events from the Observable.
func (ObservableSlice) Println ¶
func (o ObservableSlice) Println(a ...interface{}) error
Println subscribes to the Observable and prints every item to os.Stdout while it waits for completion or error. Returns either the error or nil when the Observable completed normally. Println uses a serial scheduler created with NewScheduler().
type Observer ¶
Observer is a function that gets called whenever the Observable has something to report. The next argument is the item value that is only valid when the done argument is false. When done is true and the err argument is not nil, then the Observable has terminated with an error. When done is true and the err argument is nil, then the Observable has completed normally.
type Scheduler ¶
Scheduler is used to schedule tasks to support subscribing and observing.
func NewScheduler ¶ added in v0.0.1
func NewScheduler() Scheduler
type SliceObserver ¶
SliceObserver is a function that gets called whenever the Observable has something to report. The next argument is the item value that is only valid when the done argument is false. When done is true and the err argument is not nil, then the Observable has terminated with an error. When done is true and the err argument is nil, then the Observable has completed normally.
type Subscriber ¶
type Subscriber interface {
// A Subscriber is also a Subscription.
Subscription
// Add will create and return a new child Subscriber setup in such a way that
// calling Unsubscribe on the parent will also call Unsubscribe on the child.
// Calling the Unsubscribe method on the child will NOT propagate to the
// parent!
Add() Subscriber
// OnUnsubscribe will add the given callback function to the subscriber.
// The callback will be called when either the Unsubscribe of the parent
// or of the subscriber itself is called. If the subscription was already
// canceled, then the callback function will just be called immediately.
OnUnsubscribe(callback func())
// OnWait will register a callback to call when subscription Wait is called.
OnWait(callback func())
// Done will set the error internally and then cancel the subscription by
// calling the Unsubscribe method. A nil value for error indicates success.
Done(err error)
// Error returns the error set by calling the Done(err) method. As long as
// the subscriber is still subscribed Error will return nil.
Error() error
}
Subscriber is a Subscription with management functionality.
func NewSubscriber ¶ added in v0.0.1
func NewSubscriber() Subscriber
New will create and return a new Subscriber.
type Subscription ¶ added in v0.0.1
type Subscription interface {
// Subscribed returns true when the subscription is currently active.
Subscribed() bool
// Unsubscribe will do nothing if the subscription is not active. If the
// state is still active however, it will be changed to canceled.
// Subsequently, it will call Unsubscribe on all child subscriptions added
// through Add, along with all methods added through OnUnsubscribe. When the
// subscription is canceled by calling Unsubscribe a call to the Wait method
// will return the error ErrUnsubscribed.
Unsubscribe()
// Canceled returns true when the subscription state is canceled.
Canceled() bool
// Wait will by default block the calling goroutine and wait for the
// Unsubscribe method to be called on this subscription.
// However, when OnWait was called with a callback wait function it will
// call that instead. Calling Wait on a subscription that has already been
// canceled will return immediately. If the subscriber was canceled by
// calling Unsubscribe, then the error returned is ErrUnsubscribed.
// If the subscriber was terminated by calling Done, then the error
// returned here is the one passed to Done.
Wait() error
}
Subscription is an interface that allows code to monitor and control a subscription it received.