export interface RetryOptions {
retries: number;
baseMs: number;
maxMs: number;
signal?: AbortSignal;
onRetry?: (attempt: number, delay: number, err: unknown) => void;
// Creating a Promise
const myPromise = new Promise((resolve, reject) => {
const success = true;
setTimeout(() => {
if (success) {
export type Settled<R> =
| { status: 'fulfilled'; value: R }
| { status: 'rejected'; reason: unknown };
export interface ConcurrencyOptions {
limit: number;
// Basic GET request
fetch('https://api.example.com/users')
.then(response => {
console.log('Status:', response.status);
console.log('OK:', response.ok);
return response.json();
use std::pin::Pin;
use std::future::Future;
async fn example() {
println!("Example future");
}
package com.example.demo.service;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.List;
export class QueryCache {
constructor() {
this.entries = new Map();
}
getEntry(key) {
type Loader<T> = () => Promise<T>;
interface Entry<T> {
value: T;
expiresAt: number;
}
<?php
namespace App\Event;
use Symfony\Contracts\EventDispatcher\Event;
export interface UploadHandle {
promise: Promise<{ status: number; body: string }>;
xhr: XMLHttpRequest;
}
export function uploadFile(
from typing import List, Optional
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from .dataloader import DataLoader
# Basic Ractor usage
ractor = Ractor.new do
# This runs in parallel, isolated from main thread
result = heavy_computation
result
end