Comments (3)
Hi @LucasZanella. Do
is currently not implemented, but I'll look into it.
What you wanted to do can be achieved with
// wrap a side effect in an EventHandler
handler := handlers.NextFunc(func(v interface{}) {
fmt.Println(v)
})
sc := observable.Just(1).Subscribe(handler)
<-sc
// or ...
// wrap the side effect in a MappableFunc and throw away the returned Observable
_ = observable.Just(1).Map(func(v interface{}) interface{} {
fmt.Print(v)
return nil
})
Go has no generic functions, so it is not possible for a method to accept any function outside of the typed ones declared in fx
and handlers
.
from rxgo.
@LucasZanella worth checking out this discussion on stackoverflow.
It might be interesting to have Do
as a shortcut operator for a subscription in Connectable
though, since it is a cold Observable that doesn't fire the stream on Subscribe
:
printFunc := func(item interface{}) {
fmt.Print(item)
}
c := connectable.Just(1).Subscribe(handlers.NextFunc(printFunc))
results := c.Connect()
<-results
// can be
results = connectable.Just(1).Do(printFunc).Connect()
<-results
from rxgo.
Fixed -> Implement Do Operator
from rxgo.
Related Issues (20)
- when to support the generic type HOT 1
- Why I can not find "Throttle" operator?
- [Support] Leak goroutine with rxgo.Merge HOT 1
- SwitchMap operator
- New maintainer? HOT 11
- Sometimes First().Get() not returning a context canceled error HOT 2
- Go 1.18 Generics Support
- RX driver for SQL databases
- Counting items of a Connectable Observable
- Cold & Hot Observables HOT 1
- Add `Subject` to rxgo
- There are some examples.
- Custom Producer HOT 1
- How cancel subscription ?
- How to do recursion?
- Is this still mantained? HOT 2
- RxGo Rest api example HOT 1
- mapOperator missing res when return error in "map" function HOT 1
- Adding Subjects
- Real-World Example in doc HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rxgo.