Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/socketry/async-await
Why wait? It's available today!
https://github.com/socketry/async-await
async await ruby
Last synced: 5 days ago
JSON representation
Why wait? It's available today!
- Host: GitHub
- URL: https://github.com/socketry/async-await
- Owner: socketry
- License: mit
- Created: 2017-08-17T03:46:54.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2024-06-04T05:29:26.000Z (8 months ago)
- Last Synced: 2025-01-14T11:14:11.434Z (12 days ago)
- Topics: async, await, ruby
- Language: Ruby
- Homepage:
- Size: 50.8 KB
- Stars: 74
- Watchers: 8
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# Async::Await
Implements the async/await pattern for Ruby using [async](https://github.com/socketry/async).
[![Development Status](https://github.com/socketry/async-await/workflows/Test/badge.svg)](https://github.com/socketry/async-await/actions?workflow=Test)
## Installation
``` shell
bundle add async-await
```## Usage
In any asynchronous context (e.g. a reactor), simply use the `await` function like so:
``` ruby
require 'async/await'class Coop
include Async::Await
async def count_chickens(area_name)
3.times do |i|
sleep rand
puts "Found a chicken in the #{area_name}!"
end
endasync def count_all_chickens
# These methods all run at the same time.
count_chickens("garden")
count_chickens("house")
# We wait for the result
count_chickens("tree").wait
end
endcoop = Coop.new
coop.count_all_chickens
```## Contributing
We welcome contributions to this project.
1. Fork it.
2. Create your feature branch (`git checkout -b my-new-feature`).
3. Commit your changes (`git commit -am 'Add some feature'`).
4. Push to the branch (`git push origin my-new-feature`).
5. Create new Pull Request.### Developer Certificate of Origin
This project uses the [Developer Certificate of Origin](https://developercertificate.org/). All contributors to this project must agree to this document to have their contributions accepted.
### Contributor Covenant
This project is governed by the [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.