GitLab's annual major release is around the corner. Along with a lot of new and exciting features, there will be a few breaking changes. Learn more here.

Commit e01b660a authored by Nathan Graule's avatar Nathan Graule 💻
Browse files

Merge branch 'develop' of gitlab.com:solarliner/call into develop

parents 594ab62e 7aabf24d
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- Asynchronous process of callback functions
- Ability to chain calls
- Ability to catch in chains
- Ability to block until resolve/reject
- Ability to join the underlying threads
\ No newline at end of file
# Call
Thread-based, JS-like asynchronous calls for Python. Works in both Python 2.7 and Python 3.5+.
## Install
You will be soon able to install through pypi.
```bash
git clone https://gitlab.com/solarliner/call.git
cd call
# Activate virtualenv if needed
python setup.py install
```
The library requires no other dependencies, and (will soon) support Python's `await` keyword.
## Use
Create a call:
```python
def cb(resolve, reject):
result = factorial(100)
resolve(result)
call = Call(cb)
```
Chain calls with the `then` keyword
```python
call = Call(cb).then(lambda val: print(val))
```
Catch errors:
```python
call = Call(cb)\
.then(lambda val: raise Exception())\
.catch(lambda err: print('Whoops'))
```
Compose calls:
```python
results = Call.all([Call(cb) for _ in range(10)])
```
Block thread until resolved (or raises on failure):
```python
result = call.wait()
```
Wait for call to either resolve or reject
```python
call.join()
result = call.data # Not recommended
```
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment