/** * @since 3.10.0 */ import type * as Effect from "./Effect.js" import * as internal from "./internal/stm/tSubscriptionRef.js" import type * as Option from "./Option.js" import type * as Scope from "./Scope.js" import type * as STM from "./STM.js" import type * as Stream from "./Stream.js" import type * as TPubSub from "./TPubSub.js" import type * as TQueue from "./TQueue.js" import type * as TRef from "./TRef.js" import type * as Types from "./Types.js" /** * @since 3.10.0 * @category symbols */ export const TSubscriptionRefTypeId: unique symbol = internal.TSubscriptionRefTypeId /** * @since 3.10.0 * @category symbols */ export type TSubscriptionRefTypeId = typeof TSubscriptionRefTypeId /** * A `TSubscriptionRef` is a `TRef` that can be subscribed to in order to * receive a `TDequeue` of the current value and all committed changes to the value. * * @since 3.10.0 * @category models */ export interface TSubscriptionRef extends TSubscriptionRef.Variance, TRef.TRef { /** @internal */ readonly ref: TRef.TRef /** @internal */ readonly pubsub: TPubSub.TPubSub /** @internal */ modify(f: (a: A) => readonly [B, A]): STM.STM /** * A TDequeue containing the current value of the `Ref` as well as all changes * to that value. */ readonly changes: STM.STM> } /** * @since 3.10.0 */ export declare namespace TSubscriptionRef { /** * @since 3.10.0 * @category models */ export interface Variance { readonly [TSubscriptionRefTypeId]: { readonly _A: Types.Invariant } } } /** * @since 3.10.0 * @category mutations */ export const get: (self: TSubscriptionRef) => STM.STM = internal.get /** * @since 3.10.0 * @category mutations */ export const getAndSet: { /** * @since 3.10.0 * @category mutations */ (value: A): (self: TSubscriptionRef) => STM.STM /** * @since 3.10.0 * @category mutations */ (self: TSubscriptionRef, value: A): STM.STM } = internal.getAndSet /** * @since 3.10.0 * @category mutations */ export const getAndUpdate: { /** * @since 3.10.0 * @category mutations */ (f: (a: A) => A): (self: TSubscriptionRef) => STM.STM /** * @since 3.10.0 * @category mutations */ (self: TSubscriptionRef, f: (a: A) => A): STM.STM } = internal.getAndUpdate /** * @since 3.10.0 * @category mutations */ export const getAndUpdateSome: { /** * @since 3.10.0 * @category mutations */ (f: (a: A) => Option.Option): (self: TSubscriptionRef) => STM.STM /** * @since 3.10.0 * @category mutations */ (self: TSubscriptionRef, f: (a: A) => Option.Option): STM.STM } = internal.getAndUpdateSome /** * @since 3.10.0 * @category constructors */ export const make: (value: A) => STM.STM> = internal.make /** * @since 3.10.0 * @category mutations */ export const modify: { /** * @since 3.10.0 * @category mutations */ (f: (a: A) => readonly [B, A]): (self: TSubscriptionRef) => STM.STM /** * @since 3.10.0 * @category mutations */ (self: TSubscriptionRef, f: (a: A) => readonly [B, A]): STM.STM } = internal.modify /** * @since 3.10.0 * @category mutations */ export const modifySome: { /** * @since 3.10.0 * @category mutations */ (fallback: B, f: (a: A) => Option.Option): (self: TSubscriptionRef) => STM.STM /** * @since 3.10.0 * @category mutations */ ( self: TSubscriptionRef, fallback: B, f: (a: A) => Option.Option ): STM.STM } = internal.modifySome /** * @since 3.10.0 * @category mutations */ export const set: { /** * @since 3.10.0 * @category mutations */ (value: A): (self: TSubscriptionRef) => STM.STM /** * @since 3.10.0 * @category mutations */ (self: TSubscriptionRef, value: A): STM.STM } = internal.set /** * @since 3.10.0 * @category mutations */ export const setAndGet: { /** * @since 3.10.0 * @category mutations */ (value: A): (self: TSubscriptionRef) => STM.STM /** * @since 3.10.0 * @category mutations */ (self: TSubscriptionRef, value: A): STM.STM } = internal.setAndGet /** * @since 3.10.0 * @category mutations */ export const update: { /** * @since 3.10.0 * @category mutations */ (f: (a: A) => A): (self: TSubscriptionRef) => STM.STM /** * @since 3.10.0 * @category mutations */ (self: TSubscriptionRef, f: (a: A) => A): STM.STM } = internal.update /** * @since 3.10.0 * @category mutations */ export const updateAndGet: { /** * @since 3.10.0 * @category mutations */ (f: (a: A) => A): (self: TSubscriptionRef) => STM.STM /** * @since 3.10.0 * @category mutations */ (self: TSubscriptionRef, f: (a: A) => A): STM.STM } = internal.updateAndGet /** * @since 3.10.0 * @category mutations */ export const updateSome: { /** * @since 3.10.0 * @category mutations */ (f: (a: A) => Option.Option): (self: TSubscriptionRef) => STM.STM /** * @since 3.10.0 * @category mutations */ (self: TSubscriptionRef, f: (a: A) => Option.Option): STM.STM } = internal.updateSome /** * @since 3.10.0 * @category mutations */ export const updateSomeAndGet: { /** * @since 3.10.0 * @category mutations */ (f: (a: A) => Option.Option): (self: TSubscriptionRef) => STM.STM /** * @since 3.10.0 * @category mutations */ (self: TSubscriptionRef, f: (a: A) => Option.Option): STM.STM } = internal.updateSomeAndGet /** * @since 3.10.0 * @category mutations */ export const changesScoped: (self: TSubscriptionRef) => Effect.Effect, never, Scope.Scope> = internal.changesScoped /** * @since 3.10.0 * @category mutations */ export const changesStream: (self: TSubscriptionRef) => Stream.Stream = internal.changesStream /** * @since 3.10.0 * @category mutations */ export const changes: (self: TSubscriptionRef) => STM.STM> = (self) => self.changes