Created
March 27, 2020 18:43
-
-
Save teivah/41447aa566a95e496082f1ba08f241ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ch := make(chan rxgo.Item) | |
go func() { | |
ch <- rxgo.Of(1) | |
ch <- rxgo.Of(2) | |
ch <- rxgo.Of(3) | |
close(ch) | |
}() | |
source := rxgo.FromChannel(ch, rxgo.WithPublishStrategy()) | |
obs1 := source.Map(func(_ context.Context, i interface{}) (interface{}, error) { | |
return i.(int) + 1, nil | |
}).DoOnNext(func(i interface{}) { | |
fmt.Printf("%v\n", i) | |
}) | |
obs2 := source.Map(func(_ context.Context, i interface{}) (interface{}, error) { | |
return i.(int) * 10, nil | |
}).DoOnNext(func(i interface{}) { | |
fmt.Printf("%v\n", i) | |
}) | |
source.Connect() | |
<-obs1 | |
<-obs2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment