Apollo Elements Guides API Blog

Helpers: prototypes

Helper functions to aid in prototype hacking.

Exports

import { applyPrototype } from '@apollo-elements/lib/prototypes';

applyPrototype

Applies a class' prototype to an element, mixing in the class' properties and methods to the element instance.

Parameters

host

T extends ApolloElementElement

Element to apply prototype properties to.

klass

Constructor<T> | typeof ApolloElementElement

Class whose prototype to apply to the host element.

type

'client' | 'subscription' | 'mutation' | 'query'

Hint about what kind of class/host pair is in question.

effects

(host: T) => void

function that will run the first time this element has a class prototype mixed in via this helper.

Returns

PropertyDescriptorMap

Combined PropertyDescriptorMap for the instance.