Skip to main content Link Search Menu Expand Document (external link)

TRef.ts overview

Since v2.0.0


Exports Grouped by Category


constructors

make

Signature

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

Source

Since v2.0.0

models

TRef (interface)

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

export interface TRef<in out A> extends TRef.Variance<A>, Pipeable {
  /**
   * Note: the method is unbound, exposed only for potential extensions.
   */
  modify<B>(f: (a: A) => readonly [B, A]): STM.STM<B>
}

Source

Since v2.0.0

mutations

get

Signature

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

Source

Since v2.0.0

getAndSet

Signature

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

Source

Since v2.0.0

getAndUpdate

Signature

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

Source

Since v2.0.0

getAndUpdateSome

Signature

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

Source

Since v2.0.0

modify

Signature

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

Source

Since v2.0.0

modifySome

Signature

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

Source

Since v2.0.0

set

Signature

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

Source

Since v2.0.0

setAndGet

Signature

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

Source

Since v2.0.0

update

Signature

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

Source

Since v2.0.0

updateAndGet

Signature

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

Source

Since v2.0.0

updateSome

Signature

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

Source

Since v2.0.0

updateSomeAndGet

Signature

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

Source

Since v2.0.0

symbols

TRefTypeId

Signature

declare const TRefTypeId: unique symbol

Source

Since v2.0.0

TRefTypeId (type alias)

Signature

type TRefTypeId = typeof TRefTypeId

Source

Since v2.0.0

utils

TRef (namespace)

Source

Since v2.0.0

Variance (interface)

Signature

export interface Variance<in out A> {
  readonly [TRefTypeId]: {
    readonly _A: Types.Invariant<A>
  }
}

Source

Since v2.0.0