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

Function Interval

factory.go:208–231  ·  view source on GitHub ↗

Interval creates an Observable emitting incremental integers infinitely between each given time interval.

(interval Duration, opts ...Option)

Source from the content-addressed store, hash-verified

206// Interval creates an Observable emitting incremental integers infinitely between
207// each given time interval.
208func Interval(interval Duration, opts ...Option) Observable {
209 option := parseOptions(opts...)
210 next := option.buildChannel()
211 ctx := option.buildContext(emptyContext)
212
213 go func() {
214 i := 0
215 for {
216 select {
217 case <-time.After(interval.duration()):
218 if !Of(i).SendContext(ctx, next) {
219 return
220 }
221 i++
222 case <-ctx.Done():
223 close(next)
224 return
225 }
226 }
227 }()
228 return &ObservableImpl{
229 iterable: newEventSourceIterable(ctx, next, option.getBackPressureStrategy()),
230 }
231}
232
233// Just creates an Observable with the provided items.
234func Just(items ...interface{}) func(opts ...Option) Observable {

Callers 1

Calls 8

parseOptionsFunction · 0.85
OfFunction · 0.85
newEventSourceIterableFunction · 0.85
SendContextMethod · 0.80
buildChannelMethod · 0.65
buildContextMethod · 0.65
durationMethod · 0.65

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…