Hyperlinkv0.8.0-beta.28

TxChunk

TxChunk.emptyconsteffect/TxChunk.ts:155
<A = never>(): Effect.Effect<TxChunk<A>>

Creates a new empty TxChunk.

Details

This function returns a new TxChunk reference that is initially empty. No existing TxChunk instances are modified.

Example (Creating an empty TxChunk)

import { Effect, TxChunk } from "effect"

const program = Effect.gen(function*() {
  // Create an empty TxChunk
  const txChunk = yield* TxChunk.empty<number>()

  // Check if it's empty - automatically transactional
  const isEmpty = yield* TxChunk.isEmpty(txChunk)
  console.log(isEmpty) // true

  // Add elements - automatically transactional
  yield* TxChunk.append(txChunk, 42)

  const isStillEmpty = yield* TxChunk.isEmpty(txChunk)
  console.log(isStillEmpty) // false
})
constructors
Source effect/TxChunk.ts:1552 lines
export const empty = <A = never>(): Effect.Effect<TxChunk<A>> =>
  Effect.map(TxRef.make(Chunk.empty<A>()), (ref) => makeUnsafe(ref))
Referenced by 4 symbols