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

Method ZipFromIterable

observable_operator.go:2960–3010  ·  view source on GitHub ↗

ZipFromIterable merges the emissions of an Iterable via a specified function and emit single items for each combination based on the results of this function.

(iterable Iterable, zipper Func2, opts ...Option)

Source from the content-addressed store, hash-verified

2958// ZipFromIterable merges the emissions of an Iterable via a specified function
2959// and emit single items for each combination based on the results of this function.
2960func (o *ObservableImpl) ZipFromIterable(iterable Iterable, zipper Func2, opts ...Option) Observable {
2961 option := parseOptions(opts...)
2962 next := option.buildChannel()
2963 ctx := option.buildContext(o.parent)
2964
2965 go func() {
2966 defer close(next)
2967 it1 := o.Observe(opts...)
2968 it2 := iterable.Observe(opts...)
2969 loop:
2970 for {
2971 select {
2972 case <-ctx.Done():
2973 break loop
2974 case i1, ok := <-it1:
2975 if !ok {
2976 break loop
2977 }
2978 if i1.Error() {
2979 i1.SendContext(ctx, next)
2980 return
2981 }
2982 for {
2983 select {
2984 case <-ctx.Done():
2985 break loop
2986 case i2, ok := <-it2:
2987 if !ok {
2988 break loop
2989 }
2990 if i2.Error() {
2991 i2.SendContext(ctx, next)
2992 return
2993 }
2994 v, err := zipper(ctx, i1.V, i2.V)
2995 if err != nil {
2996 Error(err).SendContext(ctx, next)
2997 return
2998 }
2999 Of(v).SendContext(ctx, next)
3000 continue loop
3001 }
3002 }
3003 }
3004 }
3005 }()
3006
3007 return &ObservableImpl{
3008 iterable: newChannelIterable(next),
3009 }
3010}

Callers

nothing calls this directly

Calls 10

ObserveMethod · 0.95
parseOptionsFunction · 0.85
ErrorFunction · 0.85
OfFunction · 0.85
newChannelIterableFunction · 0.85
SendContextMethod · 0.80
buildChannelMethod · 0.65
buildContextMethod · 0.65
ObserveMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected