All Projects → conquerant-project → conquerant

conquerant-project / conquerant

Licence: EPL-1.0 license
lightweight async/await for Clojure

Programming Languages

clojure
4091 projects

Projects that are alternatives of or similar to conquerant

Promise Fun
Promise packages, patterns, chat, and tutorials
Stars: ✭ 3,779 (+12090.32%)
Mutual labels:  promise, concurrency, async-await
P Map
Map over promises concurrently
Stars: ✭ 639 (+1961.29%)
Mutual labels:  promise, concurrency, async-await
eslint-config-welly
😎 ⚙️ ESLint configuration for React projects that I do. Feel free to use this!
Stars: ✭ 21 (-32.26%)
Mutual labels:  promise, async-await
Then
🎬 Tame async code with battle-tested promises
Stars: ✭ 908 (+2829.03%)
Mutual labels:  promise, async-await
Unityfx.async
Asynchronous operations (promises) for Unity3d.
Stars: ✭ 143 (+361.29%)
Mutual labels:  promise, async-await
Thunks
A small and magical composer for all JavaScript asynchronous.
Stars: ✭ 523 (+1587.1%)
Mutual labels:  promise, async-await
Posterus
Composable async primitives with cancelation, control over scheduling, and coroutines. Superior replacement for JS Promises.
Stars: ✭ 536 (+1629.03%)
Mutual labels:  promise, async-await
Rubico
[a]synchronous functional programming
Stars: ✭ 133 (+329.03%)
Mutual labels:  promise, async-await
Post Me
📩 Use web Workers and other Windows through a simple Promise API
Stars: ✭ 398 (+1183.87%)
Mutual labels:  promise, concurrency
Kitsu
🦊 A simple, lightweight & framework agnostic JSON:API client
Stars: ✭ 166 (+435.48%)
Mutual labels:  promise, async-await
Foy
A simple, light-weight and modern task runner for general purpose.
Stars: ✭ 157 (+406.45%)
Mutual labels:  promise, async-await
Await Of
await wrapper for easier errors handling without try-catch
Stars: ✭ 240 (+674.19%)
Mutual labels:  promise, async-await
Start
🔴 Functional task runner for Node.js
Stars: ✭ 478 (+1441.94%)
Mutual labels:  promise, concurrency
Basic Ftp
FTP client for Node.js, supports FTPS over TLS, passive mode over IPv6, async/await, and Typescript.
Stars: ✭ 441 (+1322.58%)
Mutual labels:  promise, async-await
Throat
Throttle a collection of promise returning functions
Stars: ✭ 419 (+1251.61%)
Mutual labels:  promise, concurrency
Await Handler
Basic wrapper for await that allows handling of errors without try/catch blocks
Stars: ✭ 13 (-58.06%)
Mutual labels:  promise, async-await
YACLib
Yet Another Concurrency Library
Stars: ✭ 193 (+522.58%)
Mutual labels:  promise, concurrency
P Iteration
Utilities that make array iteration easy when using async/await or Promises
Stars: ✭ 337 (+987.1%)
Mutual labels:  promise, async-await
Tascalate Concurrent
Implementation of blocking (IO-Bound) cancellable java.util.concurrent.CompletionStage and related extensions to java.util.concurrent.ExecutorService-s
Stars: ✭ 144 (+364.52%)
Mutual labels:  promise, concurrency
p-ratelimit
Promise-based utility to make sure you don’t call rate-limited APIs too quickly.
Stars: ✭ 49 (+58.06%)
Mutual labels:  promise, concurrency

conquerant

async/await for Clojure

Clojars Project Build Status codecov

A lightweight Clojure wrapper around ForkJoinPool and CompletableFuture for concurrency that is simple and easy.

Why

core.async

Usage

;; Async HTTP Exaxmple
;; ===================
(refer-clojure :exclude '[await promise])
(require '[clj-http.client :as client]
         '[conquerant.core :refer [async await promise]])

(def url "https://gist.githubusercontent.com/divs1210/2ce84f3707b785a76d225d23f18c4904/raw/2dedab13201a8a8a2c91c3800040c84b70fef2e2/data.edn")

(defn fetch [url]
  (promise [resolve]
    (client/get url
                {:async? true}
                (fn [response]
                  (resolve [response nil]))
                (fn [error]
                  (resolve [nil error])))))

(async
  (let [[response error] (await (fetch url))]
    (if error
      (println "Error:" (.getMessage error))
      (println "Response Body:" (:body response)))))

(println "fetching asynchronously...")
;; => fetching asynchronously...
;; => Response Body: {:result 1}
  • promise

    • gets value out of callback
    • runs body on a lightweight thread, returning a CompletableFuture
    • can be resolved from outside via complete
    • can be derefed: @(promise [resolve] (resolve :hi))
    • can run on a custom ExecutorService using with-async-executor
  • async

    • runs body on a lightweight thread
      • can wrap defn and fn forms - supports variadic versions
      (async (defn f
               ([a]
                 (inc a))
               ([a b]
                 (* a b))))
      • any other expression, returning a CompletableFuture (promise)
      @(async [1 2]) ;; => [1 2]
    • can run on a custom ExecutorService using with-async-executor
  • await

    • pauses the lightweight thread till the given promise is complete
    • can only be used in async let bindings
      • normal let block anywhere inside an async block
      • every let block with a call to await returns a CompletableFuture
    • works across function boundaries
    • can timeout like deref: (await p 1000 :timeout)
  • channels

Walkthrough

Clone this repo, fire up a REPL, and walk through the conquerant walkthrough.

License

Copyright © 2018 Divyansh Prakash

Distributed under the Eclipse Public License either version 1.0.

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].