Comments (2)
You shouldn't pass context on every function, because by default the context is propagate to every children. Instead you should do like this
func run(t *testing.T, run int) bool {
// create a context and cancel it after 100 ms
ctx, cancel := context.WithCancel(context.Background())
go func() {
time.Sleep(time.Millisecond * 100)
cancel()
}()
// make an observable from a channel
ch := make(chan rxgo.Item)
observable := rxgo.FromChannel(ch, rxgo.WithContext(ctx))
// use first and get to get the first matching item
i, err := observable.
Filter(func(i interface{}) bool {
return false
}).
First().
Get()
/// OR this ------------------->
observable := rxgo.FromChannel(ch)
// use first and get to get the first matching item
i, err := observable.
Filter(func(i interface{}) bool {
return false
}).
First().
Get(rxgo.WithContext(ctx))
// use to keep the item
item = i
// the error should be not nil, because context canceled
return err != nil
}
from rxgo.
@si3nloong I tested both versions of your code with github.com/reactivex/rxgo/v2 v2.5.0
, but the issue still exists.
from rxgo.
Related Issues (20)
- TakeUntil behaves differently to ReactiveX documentation
- How to pass context creating function
- Does this library support automatic back pressure ?
- How to fun out HOT 2
- JustItem(slice) will send multiple values, despite being a Single
- Observe(rxgo.WithContext(ctx)) does not cancel observable? HOT 3
- 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
- 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 ?
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.