Skip to content

Commit

Permalink
Empty operator
Browse files Browse the repository at this point in the history
  • Loading branch information
teivah committed Feb 15, 2020
1 parent e09b5aa commit 3f30d5e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 1 addition & 2 deletions assert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ func hasItems(items ...interface{}) rxAssert {
})
}

func hasNoItems(items ...interface{}) rxAssert {
func hasNoItems() rxAssert {
return newAssertion(func(a *rxAssertImpl) {
a.checkHasNoItems = true
a.items = items
})
}

Expand Down
8 changes: 8 additions & 0 deletions factory.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
package rxgo

func Empty() Observable {
next := make(chan Item)
close(next)
return &observable{
iterable: newIterable(next),
}
}

func FromChannel(next <-chan Item) Observable {
return &observable{
iterable: newIterable(next),
Expand Down
5 changes: 5 additions & 0 deletions factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import (
"testing"
)

func Test_Empty(t *testing.T) {
obs := Empty()
assertObservable(t, context.Background(), obs, hasNoItems())
}

func Test_FromChannel(t *testing.T) {
next := channelValue(1, 2, 3, closeCmd)
obs := FromChannel(next)
Expand Down

0 comments on commit 3f30d5e

Please sign in to comment.