before_next.h 568 B

1234567891011121314151617181920212223
  1. // This file is part of Desktop App Toolkit,
  2. // a set of libraries for developing nice desktop applications.
  3. //
  4. // For license and copyright information please follow this link:
  5. // https://github.com/desktop-app/legal/blob/master/LEGAL
  6. //
  7. #pragma once
  8. #include <rpl/producer.h>
  9. #include <rpl/filter.h>
  10. namespace rpl {
  11. template <typename SideEffect>
  12. inline auto before_next(SideEffect &&method) {
  13. return filter([method = std::forward<SideEffect>(method)](
  14. const auto &value) {
  15. details::callable_invoke(method, value);
  16. return true;
  17. });
  18. }
  19. } // namespace rpl