Skip to content

TRef

17 exports Added in v2.0.0 Source

Constructors

make

Added in v2.0.0 Source

Signature

declare const make: <A>(value: A) => STM.STM<TRef<A>>;

Models

TRef interface

Added in v2.0.0 Source

A TRef<A> is a purely functional description of a mutable reference that can be modified as part of a transactional effect. The fundamental operations of a TRef are set and get. set transactionally sets the reference to a new value. get gets the current value of the reference.

NOTE: While TRef<A> provides the transactional equivalent of a mutable reference, the value inside the TRef should be immutable.

Signature

interface TRef<in out A> extends Variance<A>, Pipeable {
  modify<B>(f: (a: A) => readonly [B, A]): STM<B>;
}

Mutations

get

Added in v2.0.0 Source

Signature

declare const get: <A>(self: TRef<A>) => STM.STM<A>;

getAndSet

Added in v2.0.0 Source

Signature

declare const getAndSet: {
  <A>(value: A): (self: TRef<A>) => STM<A>;
  <A>(self: TRef<A>, value: A): STM<A>;
};

getAndUpdate

Added in v2.0.0 Source

Signature

declare const getAndUpdate: {
  <A>(f: (a: A) => A): (self: TRef<A>) => STM<A>;
  <A>(self: TRef<A>, f: (a: A) => A): STM<A>;
};

Signature

declare const getAndUpdateSome: {
  <A>(f: (a: A) => Option<A>): (self: TRef<A>) => STM<A>;
  <A>(self: TRef<A>, f: (a: A) => Option<A>): STM<A>;
};

modify

Added in v2.0.0 Source

Signature

declare const modify: {
  <A, B>(f: (a: A) => readonly [B, A]): (self: TRef<A>) => STM<B>;
  <A, B>(self: TRef<A>, f: (a: A) => readonly [B, A]): STM<B>;
};

modifySome

Added in v2.0.0 Source

Signature

declare const modifySome: {
  <A, B>(fallback: B, f: (a: A) => Option<readonly [B, A]>): (self: TRef<A>) => STM<B>;
  <A, B>(self: TRef<A>, fallback: B, f: (a: A) => Option<readonly [B, A]>): STM<B>;
};

set

Added in v2.0.0 Source

Signature

declare const set: {
  <A>(value: A): (self: TRef<A>) => STM<void>;
  <A>(self: TRef<A>, value: A): STM<void>;
};

setAndGet

Added in v2.0.0 Source

Signature

declare const setAndGet: {
  <A>(value: A): (self: TRef<A>) => STM<A>;
  <A>(self: TRef<A>, value: A): STM<A>;
};

update

Added in v2.0.0 Source

Signature

declare const update: {
  <A>(f: (a: A) => A): (self: TRef<A>) => STM<void>;
  <A>(self: TRef<A>, f: (a: A) => A): STM<void>;
};

updateAndGet

Added in v2.0.0 Source

Signature

declare const updateAndGet: {
  <A>(f: (a: A) => A): (self: TRef<A>) => STM<A>;
  <A>(self: TRef<A>, f: (a: A) => A): STM<A>;
};

updateSome

Added in v2.0.0 Source

Signature

declare const updateSome: {
  <A>(f: (a: A) => Option<A>): (self: TRef<A>) => STM<void>;
  <A>(self: TRef<A>, f: (a: A) => Option<A>): STM<void>;
};

Signature

declare const updateSomeAndGet: {
  <A>(f: (a: A) => Option<A>): (self: TRef<A>) => STM<A>;
  <A>(self: TRef<A>, f: (a: A) => Option<A>): STM<A>;
};

Other

TRef

Added in v2.0.0 Source

Symbols

TRefTypeId

Added in v2.0.0 Source

Signature

declare const TRefTypeId: unique symbol;

TRefTypeId type

Added in v2.0.0 Source

Signature

type TRefTypeId = typeof TRefTypeId;