Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

JustItem(slice) will send multiple values, despite being a Single #341

Open
hexaglow opened this issue Jan 10, 2022 · 0 comments · May be fixed by #378
Open

JustItem(slice) will send multiple values, despite being a Single #341

hexaglow opened this issue Jan 10, 2022 · 0 comments · May be fixed by #378
Assignees
Labels
bug report Reported bug.

Comments

@hexaglow
Copy link

Describe the bug
When called with a slice, JustItem returns a Single that sends multiple values. However the documentation (and the name) suggests that a Single should send one value. There appears to be no way to send a slice as a single value, which is very counterintuitive!

To Reproduce
The following code demsonstrates the issue: (also on Go playground)

package main

import (
    "fmt"

    "github.com/reactivex/rxgo/v2"
)

func main() {
    data := []int{1, 2, 3}
    observable := rxgo.JustItem(data)

    for x := range observable.Observe() {
	    fmt.Println("Item:", x.V)
    }
}

Produces output:

Item: 1
Item: 2
Item: 3

Expected behavior
Output:

Item: [1 2 3]

Additional context
The problem appears to be caused by the send function (item.go:75) which switches on the type of each item.

@hexaglow hexaglow added the bug report Reported bug. label Jan 10, 2022
si3nloong added a commit to si3nloong/RxGo that referenced this issue Aug 31, 2022
@si3nloong si3nloong linked a pull request Aug 31, 2022 that will close this issue
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug report Reported bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants