Skip to content

Instantly share code, notes, and snippets.

@tom-huntington
Last active July 21, 2022 21:24
Show Gist options
  • Save tom-huntington/6225efeeccbdc1610641c199c976f78a to your computer and use it in GitHub Desktop.
Save tom-huntington/6225efeeccbdc1610641c199c976f78a to your computer and use it in GitHub Desktop.
RxCpp-v3 adaptor

Concepts

struct observable {
    void bind(observer);
};

struct observer {
    template<class T>
    void next(T);
};

struct lifter {
    observer lift(observer);
};

Doesn't work, just saving thoughts for later

const auto buffer_until = [](observable signal){
  auto queue = make_shared<std::queue>();
  make_lifter([=](auto r){
    signal.bind(make_observer(r, [=](auto& r, auto v){
        while (queue->front() < v) r.next(queue->pop());
    });
    return make_observer([=](auto&, auto v){
        q->push(v);
    });
  });
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment