All Projects β†’ botsman β†’ hxasync

botsman / hxasync

Licence: MIT license
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.

Programming Languages

haxe
709 projects

Projects that are alternatives of or similar to hxasync

Asyncex
A helper library for async/await.
Stars: ✭ 2,794 (+13204.76%)
Mutual labels:  await
micro-chain
🀝 Helps to build chains from your micro services.
Stars: ✭ 24 (+14.29%)
Mutual labels:  await
of
🍬 Promise wrapper with sugar 🍬
Stars: ✭ 13 (-38.1%)
Mutual labels:  await
Await Of
await wrapper for easier errors handling without try-catch
Stars: ✭ 240 (+1042.86%)
Mutual labels:  await
WebsocketPromisify
Makes websocket's API just like REST with Promise-like API, with native Promises.
Stars: ✭ 18 (-14.29%)
Mutual labels:  await
best-queue
Queue in runtime based promise
Stars: ✭ 26 (+23.81%)
Mutual labels:  await
Use Async Effect
πŸƒ Asynchronous side effects, without the nonsense
Stars: ✭ 193 (+819.05%)
Mutual labels:  await
AsyncLock
An async/await-friendly lock for .NET, complete with asynchronous waits, safe reëntrance, and more.
Stars: ✭ 106 (+404.76%)
Mutual labels:  await
do
Simplest way to manage asynchronicity
Stars: ✭ 33 (+57.14%)
Mutual labels:  await
ProtoPromise
Robust and efficient library for management of asynchronous operations in C#/.Net.
Stars: ✭ 20 (-4.76%)
Mutual labels:  await
csharp-workshop
NDC London 2019, Workshop: Become a better C# programmer: more Value, more Expressions, no Waiting
Stars: ✭ 21 (+0%)
Mutual labels:  await
try-to-catch
functional try-catch wrapper for promises
Stars: ✭ 30 (+42.86%)
Mutual labels:  await
Promise.allSettled
ES Proposal spec-compliant shim for Promise.allSettled
Stars: ✭ 93 (+342.86%)
Mutual labels:  await
Coerce Rs
Coerce - an asynchronous (async/await) Actor runtime and cluster framework for Rust
Stars: ✭ 231 (+1000%)
Mutual labels:  await
helo
A simple and small low-level asynchronous ORM using Python asyncio.
Stars: ✭ 18 (-14.29%)
Mutual labels:  await
Taskbuilder.fs
F# computation expression builder for System.Threading.Tasks
Stars: ✭ 217 (+933.33%)
Mutual labels:  await
relaks
Asynchrounous React component
Stars: ✭ 49 (+133.33%)
Mutual labels:  await
is-async-function
Is this a native `async function`?
Stars: ✭ 17 (-19.05%)
Mutual labels:  await
synchronicity
Synchronicity lets you interoperate with asynchronous Python APIs.
Stars: ✭ 41 (+95.24%)
Mutual labels:  await
sleepover
πŸ’€ Sleep, snooze & step methods
Stars: ✭ 13 (-38.1%)
Mutual labels:  await

HXAsync

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.
Theoretically, support of C# could be added since Haxe 4.2 if there is such a demand.

Used internally for my personal projects.

Example:

Haxe source code

@: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 main() {
    var example = new MyExample();
    return @await example.some();
  }
}

Python output (some Haxe-generated output is omitted)

class MyExample:
    __slots__ = ()

    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)

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();
	}
}

Instead of using bare async and await keywords, I had to use Haxe meta-tags @async and @await.
I tried to keep the implementation as close as possible to the native target platforms implementation.

Usage

In order to start using this macros, you need to:

  1. Install the library: haxelib install hxasync
  2. Add the library to your project when compiling a project: -lib hxasync
  3. Do one of these to enable async and await feature for your class:
    • use build or autobuild macros:
    @:build(hxasync.AsyncMacro.build())  
    class MyClass {}  
    
    • implement Asyncable interface:
    class MyClass implements hxasync.Asyncable {}   
    
    • apply AsyncMacro to all classes in a specified package:
      --macro hxasync.AsyncMacro.makeAsyncable("")

Project is inspired by hx-jsasync library.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].