TRef overview
Added in v2.0.0
Table of contents
constructors
make
Signature
export declare const make: <A>(value: A) => STM.STM<TRef<A>>
Added in 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> {
/**
* Note: the method is unbound, exposed only for potential extensions.
*/
modify<B>(f: (a: A) => readonly [B, A]): STM.STM<B>
}
Added in v2.0.0
mutations
get
Signature
export declare const get: <A>(self: TRef<A>) => STM.STM<A>
Added in v2.0.0
getAndSet
Signature
export declare const getAndSet: {
<A>(value: A): (self: TRef<A>) => STM.STM<A>
<A>(self: TRef<A>, value: A): STM.STM<A>
}
Added in v2.0.0
getAndUpdate
Signature
export 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>
}
Added in v2.0.0
getAndUpdateSome
Signature
export 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>
}
Added in v2.0.0
modify
Signature
export 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>
}
Added in v2.0.0
modifySome
Signature
export 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>
}
Added in v2.0.0
set
Signature
export declare const set: {
<A>(value: A): (self: TRef<A>) => STM.STM<void>
<A>(self: TRef<A>, value: A): STM.STM<void>
}
Added in v2.0.0
setAndGet
Signature
export declare const setAndGet: {
<A>(value: A): (self: TRef<A>) => STM.STM<A>
<A>(self: TRef<A>, value: A): STM.STM<A>
}
Added in v2.0.0
update
Signature
export 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>
}
Added in v2.0.0
updateAndGet
Signature
export 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>
}
Added in v2.0.0
updateSome
Signature
export 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>
}
Added in v2.0.0
updateSomeAndGet
Signature
export 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>
}
Added in v2.0.0
symbols
TRefTypeId
Signature
export declare const TRefTypeId: typeof TRefTypeId
Added in v2.0.0
TRefTypeId (type alias)
Signature
export type TRefTypeId = typeof TRefTypeId
Added in v2.0.0
utils
TRef (namespace)
Added in v2.0.0
Variance (interface)
Signature
export interface Variance<in out A> {
readonly [TRefTypeId]: {
readonly _A: Types.Invariant<A>
}
}
Added in v2.0.0