vavr
vavr copied to clipboard
Add `sample` support for function obj.
Functions are first-class citizens.
Is it possible to provide more operators to the function object.
For example, if I want a function to be executed at sampling intervals.
Using Lazy can be done only once.
Whether to consider adding a module so that the function object can be executed at intervals?
E.g:
sample(() -> { /* lambda */ }, (Predicate) () -> {/* Triggering conditions */ });
I think the sampling function will be used in monitoring, logging, reporting and other scenarios.
If you think it is necessary, I will provide a PR.
This sounds a little bit like sth we planned (or already have) as part of our vavr-test module.
Personally I think, that we leave Vavr's core domain here. In your other issue #2625 you talked about async computations. This issue sounds a little bit like rate limiting to me. I suggest that you take a look at reactive programming libraries for Java. I'm sure they come with solutions for your programming tasks. Additionally, they might compose well with Vavr.
You mentioned in #2625 to keep the API surface area relatively small, that's good.
But in actual systems, people hope to use VAVR to achieve higher-level functions(Using the basic API cannot directly provide effective functions).
Is there a place for higher-level APIs to be implemented? because I did not find too many functions in the vavr-test module.
Wish VAVR will be better in 2021.