Apollo Elements Apollo Elements Guides API Blog Toggle darkmode

Helpers: Decorators

Decorators for Apollo Elements. Used internally to reflect properties from controllers to their elements. Normally you shouldn't need to import these directly.

import { controlled } from '@apollo-elements/core/decorators';

class ControlledData<D extends MaybeTDN, V = MaybeVariables<D>> extends LitElement {
  controller = new ApolloQueryController<D, V>(this);

  @controlled()
  @state()
  data: Data<D> | null = null;
}

getInitialProps

Parameters

obj

T

Returns

Map<keyof T, T[keyof T]>

getInitialProp

Parameters

obj

T

key

keyof T

Returns

T[keyof T] | undefined

setInitialProps

Parameters

obj

T

Returns

void

setInitialProp

Parameters

obj

T

key

keyof T

value

T[keyof T]

Returns

void

controlled

Class field decorator for controlled properties

Controlled properties are element class fields which defer to and reflect that property on the element's controller property, which is a ReactiveController.

Parameters

options

DefineOptions

Options for the controlled field

Property Type Description
path 'options' Optional. When set, the field will reflect the property at the specified path, i.e. controller.options.
readonly boolean Optional. When set, setting the field will have no effect.
onSet (x: unknown) => void Optional. When defined, setting the field will have no effect.

Exports

import {
  getInitialProps,
  getInitialProp,
  setInitialProps,
  setInitialProp,
  controlled
} from '@apollo-elements/core/decorators';