Skip to content

Commit

Permalink
add more examples
Browse files Browse the repository at this point in the history
  • Loading branch information
botsman committed Jan 24, 2021
1 parent 91e4852 commit f6ddc55
Showing 1 changed file with 65 additions and 8 deletions.
73 changes: 65 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,75 @@ Project is at very beginning. Probably a lot of bugs.

This library allows you to add `async` and `await` keywords in Python and JavaScript code almost the same way you would do it in the native code.

Example:
Example:

Haxe source code

```haxe
@:build(hxasync.AsyncMacro.build())
class MyExample {
public function new() { }
@async public function myPromise() {
return "something";
}
@async public function some() {
return @await this.myPromise();
}
}
```
@:build(hxasync.AsyncMacro.build())
class Main {
@async public static function some() {
return @await somePromise;
}
@async public static function main() {
var example = new MyExample();
return @await example.some();
}
}
```

Python output (some Haxe-generated output is omitted)
```python
class MyExample:
__slots__ = ()

@async public static function another() {
return @await Main.some()
}
def __init__(self):
pass

async def myPromise(self):
return "something"

async def some(self):
return await self.myPromise()



class Main:
__slots__ = ()

@staticmethod
async def main():
example = MyExample()
return await example.some()
```

JavaScript output (some Haxe-generated output is omitted)
```js
class MyExample {
constructor() {
}
async myPromise() {
return "something";
}
async some() {
return await this.myPromise();
}
}
class Main {
static async main() {
let example = new MyExample();
return await example.some();
}
}
```

Expand Down

0 comments on commit f6ddc55

Please sign in to comment.