Comments (5)
@mincequi,
To be honest, you can achieve requested behavior with something like this:
#include <rpp/rpp.hpp>
#include <iostream>
auto sample_with_time_oversampling(rpp::schedulers::duration period, const auto& scheduler)
{
return [=](const auto& observable)
{
return rpp::source::interval(period, scheduler)
.with_latest_from([](const auto&, const auto& v) { return v; }, observable);
};
}
int main()
{
auto start = rpp::schedulers::clock_type::now();
rpp::source::interval(std::chrono::milliseconds{1000}, rpp::schedulers::trampoline{})
.op(sample_with_time_oversampling(std::chrono::milliseconds{500},
rpp::schedulers::trampoline{}))
.take(10)
.subscribe([&](size_t v)
{
std::cout << "get value " << v << " at " << std::chrono::duration_cast<std::chrono::milliseconds>(rpp::schedulers::clock_type::now() - start) << std::endl;
});
return 0;
}
Output:
get value 0 at 1008ms
get value 0 at 1506ms
get value 1 at 2010ms
get value 1 at 2504ms
get value 2 at 3004ms
get value 2 at 3512ms
get value 3 at 4005ms
get value 3 at 4513ms
get value 4 at 5008ms
get value 4 at 5502ms
from reactiveplusplus.
Ohh, i see.
I have both, but not time-based versions. I've created issues for them
#312
#313
from reactiveplusplus.
Hi @mincequi,
I'm not sure if it is expected behavior... "demo" for this operator from ReactiveX proves that no any additional emission in case of oversampling:
Same about RxJava. In place of emitting value it "clears" old value, so it is not possible that operator emits same value twice:
void emit()
{
T value = getAndSet(null);
if (value != null) {
downstream.onNext(value);
}
from reactiveplusplus.
Hi @victimsnino ,
yes, apparently the official behaviour is only undersampling. (like it is done in rxJava).
For that reason, i would need a time based window or time based buffer operator to tackle my desired behaviour.
So my question is, do you plan to realise buffer or window operator any time soon?
This is probably my last request for now :)
from reactiveplusplus.
Closing due to inactivity
from reactiveplusplus.
Related Issues (20)
- Add effective spinlock implementation and use it in operators
- Polish early_unsubscribe HOT 2
- Split "lift" to declaration and implementation
- Re-implement scheduler's related code HOT 3
- Fails to compile with clang11 HOT 5
- Rpp doesn't compile - VS22 - Windows - Latest release HOT 10
- timeout operator HOT 7
- Create document "How to create custom operator"
- QT support
- macOS/clang support HOT 28
- Create behavior subject
- Create pool based schedulers: IO and Computation HOT 5
- Re-implement scheduler's related code
- Implement debounce operator
- Add average operator (and other statistical) HOT 3
- Add window_with_time operator
- Add buffer_with_time operator
- Consider pushing builds to NUGet HOT 1
- RPP v2 - Implementation Status
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 reactiveplusplus.