reactphp / reactphp

Event-driven, non-blocking I/O with PHP.

Home Page:https://reactphp.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Way to change sync working code into async code?

lrembacz opened this issue · comments

Hi there!
I have discovered ReactPHP pretty recently and I like it pretty much, so really nice work!
But I have a question about:
How actually can we rewrite whole sync features into async one in a simple way?
Is there any tutorial how to do it?
Is there a way to just pack a work of some code into stream just with Promises or Observables such like RxPHP? Or we need to rewrite a given C/C++ library from scratch?
I actually need to use SQLite for my project. But I tihnk there will be even more libraries I need

@lrembacz Welcome to @reactphp! 🎉

It's a bit unclear what you're trying to achieve from the details you've posted, so let me try to give you a quick overview:

For many blocking things there are non-blocking alternatives. In your example, you may want to take a look at https://github.com/clue/reactphp-sqlite (WIP at the moment). See also https://github.com/reactphp/react/wiki/Users for many many possible use cases and existing implementations.

If you're completely new to @reactphp, I would highly recommend @seregazhuk's excellent blog articles and video tutorials: https://sergeyzhuk.me/reactphp-series. If you have any questions, you can always reach out to us on Twitter or IRC: https://reactphp.org/#support

I hope this helps you getting started, cheers! 🍻