I'm learning reactive for c++ and I'm looking for some guidance. I've created a function to wait for an event then return it. I want to catch all the events that occur with reactive async and handle them as they come. Here's what I have so far:
int Engine::Initialize()
{
al_init();
display = al_create_display(1200, 800);
eventQueue = al_create_event_queue();
al_install_mouse();
al_install_keyboard();
al_register_event_source(eventQueue, al_get_keyboard_event_source());
al_register_event_source(eventQueue, al_get_mouse_event_source());
//test: wait for 2 events to happen
auto events = rxcpp::observable<>::create([](rxcpp::subscriber<ALLEGRO_EVENT> e)
{
e.on_next(WaitForEvent);
e.on_next(WaitForEvent);
e.on_completed();
});
events.subscribe([](ALLEGRO_EVENT e)
{
printf("We have an Event: %d \n", e.type);
},
[]()
{
printf("Done\n");
});
return 0;
}
ALLEGRO_EVENT Engine::WaitForEvent()
{
ALLEGRO_EVENT event;
al_wait_for_event(eventQueue, &event);
return event;
}
I seem to get the error: no instance of function template "rxcpp::observable::create" matches the argument list. Do I need to make my own template or something to be able to observe an ALLEGRO_EVENT?