MCPcopy Create free account
hub / github.com/Effect-TS/effect / waiting

Function waiting

packages/effect/src/unstable/reactivity/AsyncResult.ts:366–378  ·  view source on GitHub ↗
(self: R, options?: {
  readonly touch?: boolean | undefined
})

Source from the content-addressed store, hash-verified

364 * @since 4.0.0
365 */
366export const waiting = <R extends AsyncResult<any, any>>(self: R, options?: {
367 readonly touch?: boolean | undefined
368}): R => {
369 if (self.waiting) {
370 return options?.touch ? touch(self) : self
371 }
372 const result = Object.assign(Object.create(ResultProto), self)
373 result.waiting = true
374 if (options?.touch && isSuccess(result)) {
375 ;(result as any).timestamp = Date.now()
376 }
377 return result
378}
379
380/**
381 * Refreshes the timestamp of a `Success` result while preserving its value and waiting flag; non-success results are returned unchanged.

Callers 1

waitingFromFunction · 0.85

Calls 3

touchFunction · 0.85
assignMethod · 0.80
isSuccessFunction · 0.70

Tested by

no test coverage detected