Skip to main content
Module

x/async/mod.ts>AsyncValue

🦕 Asynchronous primitive modules for Deno.
Go to Latest
class AsyncValue
import { AsyncValue } from "https://deno.land/x/async@v2.0.2/mod.ts";

A class that wraps a value and allows it to be set asynchronously.

import { assertEquals } from "https://deno.land/std@0.186.0/testing/asserts.ts";
import { AsyncValue } from "./testutil.ts";

const v = new AsyncValue(0);
assertEquals(await v.get(), 0);
await v.set(1);
assertEquals(await v.get(), 1);

Constructors

new
AsyncValue(value: T)

Constructs a new AsyncValue with the given initial value.

Methods

get(): Promise<T>

Returns the current value.

set(value: T): Promise<void>

Sets the value.