I wrote a library to augment PHP async iterators atop AmPHP
When I posted here about a project embodying the ReactiveX-for-iterators idea in Hack, I didn't think that a PHP port was possible because I thought async iteration required an await mechanic to be built into the language. When I learned about AmPHP, I'd never buried a belief so fast. yield your futures to this overarching scheduler and voilà: await-async! I found it to be really elegant, and it was even more fully-featured than Hack's minimal async core, so I ported it over and, in many places, with much greater ease thanks to AmPHP's feature set. (thanks u/SavishSalacious and u/assertchris for exposing my ignorance!)
AmpReactor now brings cloning and ReactiveX operators on AmPHP's Iterators, so in many ways it strives to be to AmPHP as RxPHP is to ReactPHP. The most immediate addition is that Iterators can be consumed by more than one consumer, with choices for buffering policies (from none to all the things!) Like the Hack library, AmpReactor includes most of the ReactiveX operators, and in particular some of the less trivial ones like merge, flat_map, group_by and the zip family. Specific to AmPHP, never is now possible!
I raced to understand AmPHP mechanics to get this off the ground as quickly as I could, so while I'm happy it's doing the right things in tests, I'm always wide open to corrections and opinions, as aggressive as they need to be. I hope this can be useful to some, and I'm always appreciative of feedback!
Posted Jul 16, 2017, 10:26 PM UTC