(ctx context.Context, f func(interface{}) int, notif chan Item, observe <-chan Item, next chan Item, operatorFactory func() operator, option Option, opts ...Option)
| 384 | } |
| 385 | |
| 386 | func 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 | |
| 423 | func (o *ObservableImpl) serialize(parent context.Context, fromCh chan Item, identifier func(interface{}) int, opts ...Option) Observable { |
| 424 | option := parseOptions(opts...) |
no test coverage detected
searching dependent graphs…