Hyperlinkv0.8.0-beta.28

Context

Context.getOrUndefinedconsteffect/Context.ts:838
<S, I>(key: Key<I, S>): <Services>(
  self: Context<Services>
) => S | undefined
<Services, S, I>(self: Context<Services>, key: Key<I, S>): S | undefined

Returns the service currently stored for a key, or undefined when the key is absent.

When to use

Use when you need to read the service stored for a key without resolving Context.Reference defaults.

Gotchas

This is a raw lookup and does not resolve default values for Context.Reference keys.

gettersgetOption
Source effect/Context.ts:8387 lines
export const getOrUndefined: {
  <S, I>(key: Key<I, S>): <Services>(self: Context<Services>) => S | undefined
  <Services, S, I>(self: Context<Services>, key: Key<I, S>): S | undefined
} = dual(
  2,
  <Services, S, I>(self: Context<Services>, key: Key<I, S>): S | undefined => self.mapUnsafe.get(key.key)
)
Referenced by 2 symbols