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

Function runFirstItem

observable.go:386–421  ·  view source on GitHub ↗
(ctx context.Context, f func(interface{}) int, notif chan Item, observe <-chan Item, next chan Item, operatorFactory func() operator, option Option, opts ...Option)

Source from the content-addressed store, hash-verified

384}
385
386func runFirstItem(ctx context.Context, f func(interface{}) int, notif chan Item, observe <-chan Item, next chan Item, operatorFactory func() operator, option Option, opts ...Option) {
387 go func() {
388 op := operatorFactory()
389 stopped := false
390 operator := operatorOptions{
391 stop: func() {
392 if option.getErrorStrategy() == StopOnError {
393 stopped = true
394 }
395 },
396 resetIterable: func(newIterable Iterable) {
397 observe = newIterable.Observe(opts...)
398 },
399 }
400
401 loop:
402 for !stopped {
403 select {
404 case <-ctx.Done():
405 break loop
406 case i, ok := <-observe:
407 if !ok {
408 break loop
409 }
410 if i.Error() {
411 op.err(ctx, i, next, operator)
412 i.SendContext(ctx, notif)
413 } else {
414 op.next(ctx, i, next, operator)
415 Of(f(i.V)).SendContext(ctx, notif)
416 }
417 }
418 }
419 op.end(ctx, next)
420 }()
421}
422
423func (o *ObservableImpl) serialize(parent context.Context, fromCh chan Item, identifier func(interface{}) int, opts ...Option) Observable {
424 option := parseOptions(opts...)

Callers 1

observableFunction · 0.85

Calls 8

OfFunction · 0.85
SendContextMethod · 0.80
getErrorStrategyMethod · 0.65
ObserveMethod · 0.65
ErrorMethod · 0.65
errMethod · 0.65
nextMethod · 0.65
endMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…