{"id":13405440,"url":"https://github.com/ReactiveX/RxPHP","last_synced_at":"2025-03-14T09:33:02.282Z","repository":{"id":45157045,"uuid":"50257587","full_name":"ReactiveX/RxPHP","owner":"ReactiveX","description":"Reactive extensions for PHP","archived":false,"fork":false,"pushed_at":"2024-09-23T19:18:48.000Z","size":1016,"stargazers_count":1700,"open_issues_count":14,"forks_count":140,"subscribers_count":95,"default_branch":"master","last_synced_at":"2024-10-29T11:24:47.187Z","etag":null,"topics":["asynchronous","observables","reactivex","rxphp"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ReactiveX.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-01-23T20:44:18.000Z","updated_at":"2024-10-27T19:42:56.000Z","dependencies_parsed_at":"2024-10-26T00:40:43.817Z","dependency_job_id":"812efe52-2cab-4354-b18f-a4722ad8b78d","html_url":"https://github.com/ReactiveX/RxPHP","commit_stats":{"total_commits":411,"total_committers":16,"mean_commits":25.6875,"dds":0.5255474452554745,"last_synced_commit":"eee8eb20ec310632d0356ff1bcaccf5c90094ba6"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactiveX%2FRxPHP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactiveX%2FRxPHP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactiveX%2FRxPHP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactiveX%2FRxPHP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ReactiveX","download_url":"https://codeload.github.com/ReactiveX/RxPHP/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243088649,"owners_count":20234423,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asynchronous","observables","reactivex","rxphp"],"created_at":"2024-07-30T19:02:02.230Z","updated_at":"2025-03-14T09:33:02.025Z","avatar_url":"https://github.com/ReactiveX.png","language":"PHP","readme":"RxPHP\n======\n\nReactive extensions for PHP. The reactive extensions for PHP are a set of\nlibraries to compose asynchronous and event-based programs using observable\nstreams.\n\n[![CI status](https://github.com/ReactiveX/RxPHP/workflows/CI/badge.svg)](https://github.com/ReactiveX/RxPHP/actions)\n[![Coverage Status](https://coveralls.io/repos/github/ReactiveX/RxPHP/badge.svg?branch=master)](https://coveralls.io/github/ReactiveX/RxPHP?branch=master)\n\n## Example\n\n```php\n$source = \\Rx\\Observable::fromArray([1, 2, 3, 4]);\n\n$source-\u003esubscribe(\n    function ($x) {\n        echo 'Next: ', $x, PHP_EOL;\n    },\n    function (Exception $ex) {\n        echo 'Error: ', $ex-\u003egetMessage(), PHP_EOL;\n    },\n    function () {\n        echo 'Completed', PHP_EOL;\n    }\n);\n\n//Next: 1\n//Next: 2\n//Next: 3\n//Next: 4\n//Completed\n\n```\n\n## Try out the demos\n\n```bash\n$ git clone https://github.com/ReactiveX/RxPHP.git\n$ cd RxPHP\n$ composer install\n$ php demo/interval/interval.php\n```\n\nHave fun running the demos in `/demo`.\n\nnote:  When running the demos, the scheduler is automatically bootstrapped.  When using RxPHP within your own project, you'll need to set the default scheduler. \n\n## Installation\n1. Install an event loop.  Any event loop should work, but the ReactPHP event loop is recommended.\n\n```bash\n$ composer require react/event-loop\n```\n\n2. Install RxPHP using [composer](https://getcomposer.org).\n\n```bash\n$ composer require reactivex/rxphp\n```\n\n3. Write some code.\n\n```PHP\n\u003c?php\n\nrequire_once __DIR__ . '/vendor/autoload.php';\n\nuse Rx\\Observable;\nuse React\\EventLoop\\Factory;\nuse Rx\\Scheduler;\n\n$loop = Factory::create();\n\n//You only need to set the default scheduler once\nScheduler::setDefaultFactory(function() use($loop){\n    return new Scheduler\\EventLoopScheduler($loop);\n});\n\nObservable::interval(1000)\n    -\u003etake(5)\n    -\u003eflatMap(function ($i) {\n        return Observable::of($i + 1);\n    })\n    -\u003esubscribe(function ($e) {\n        echo $e, PHP_EOL;\n    });\n\n$loop-\u003erun();\n\n```\n## Working with Promises\n\nSome async PHP frameworks have yet to fully embrace the awesome power of observables.  To help ease the transition, RxPHP has built in support for [ReactPHP promises](https://github.com/reactphp/promise).\n\nMixing a promise into an observable stream:\n\n```PHP\nObservable::interval(1000)\n    -\u003eflatMap(function ($i) {\n        return Observable::fromPromise(\\React\\Promise\\resolve(42 + $i));\n    })\n    -\u003esubscribe(function ($v) {\n        echo $v . PHP_EOL;\n    });\n```\n\nConverting an Observable into a promise. (This is useful for libraries that use generators and coroutines):\n```PHP\n$observable = Observable::interval(1000)\n    -\u003etake(10)\n    -\u003etoArray()\n    -\u003emap('json_encode');\n\n$promise = $observable-\u003etoPromise();\n```\n\n## Additional Information\n- [The Official Reactive Extensions Documentation](http://reactivex.io/documentation/observable.html)\n- [A Simple Introduction to Observables](https://www.youtube.com/watch?v=uQ1zhJHclvs)(video)\n\n\n## License\n\nRxPHP is licensed under the MIT License - see the LICENSE file for details\n","funding_links":[],"categories":["PHP","目录","Table of Contents"],"sub_categories":["事件 Event","Event"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FReactiveX%2FRxPHP","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FReactiveX%2FRxPHP","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FReactiveX%2FRxPHP/lists"}