Skip to main content

Abstract Class: LifecycleComponent<P, Contexts>

Defined in: src/sdk/components/common/LifecycleComponent.ts:16

An implementation of DisplayComponent which creates its own Lifecycle implementation that can be tied to subscriptions created within the component.

This component provides pause() and resume() methods, which act upon the attached lifecycle and the first LifecycleComponent in each branch of its children component tree.

This component also, by default, destroys the first DisplayComponent in each branch of its children component tree when it is itself destroyed.

Extends

Type Parameters

Type ParameterDefault type
P-
Contexts extends unknown[][]

Constructors

Constructor

new LifecycleComponent<P, Contexts>(props): LifecycleComponent<P, Contexts>

Defined in: src/sdk/components/FSComponent.ts:73

Creates an instance of a DisplayComponent.

Parameters

ParameterTypeDescription
propsPThe propertis of the component.

Returns

LifecycleComponent<P, Contexts>

Inherited from

DisplayComponent.constructor

Properties

context?

optional context: [...ContextSubcriptions<Contexts>[]] = undefined

Defined in: src/sdk/components/FSComponent.ts:64

The context on this component, if any.

Inherited from

DisplayComponent.context


contextType?

readonly optional contextType: readonly [ContextTypes<Contexts>] = undefined

Defined in: src/sdk/components/FSComponent.ts:67

The type of context for this component, if any.

Inherited from

DisplayComponent.contextType


defaultLifecycle

protected readonly defaultLifecycle: Lifecycle

Defined in: src/sdk/components/common/LifecycleComponent.ts:18

The default lifecycle to use to managed subscriptions.


props

props: P & ComponentProps

Defined in: src/sdk/components/FSComponent.ts:61

The properties of the component.

Inherited from

DisplayComponent.props


thisNode?

protected optional thisNode: VNode

Defined in: src/sdk/components/common/LifecycleComponent.ts:20

Methods

createDefaultLifecycle()

protected createDefaultLifecycle(): Lifecycle

Defined in: src/sdk/components/common/LifecycleComponent.ts:26

Creates the component's default lifecycle.

Returns

Lifecycle

A lifecycle to use as the default.


destroy()

destroy(): void

Defined in: src/sdk/components/common/LifecycleComponent.ts:43

Destroys this component.

Returns

void

Overrides

DisplayComponent.destroy


forChildNodes()

protected forChildNodes(fn): void

Defined in: src/sdk/components/common/LifecycleComponent.ts:70

Iterates over immediate child nodes.

Parameters

ParameterTypeDescription
fn(n) => voidThe function to call when a LifecycleComponent is found.

Returns

void


getContext()

protected getContext(context): ContextSubcriptions<Contexts>[number]

Defined in: src/sdk/components/FSComponent.ts:106

Gets a context data subscription from the context collection.

Parameters

ParameterTypeDescription
contextContextTypes<Contexts>[number]The context to get the subscription for.

Returns

ContextSubcriptions<Contexts>[number]

The requested context.

Throws

An error if no data for the specified context type could be found.

Inherited from

DisplayComponent.getContext


onAfterRender()

onAfterRender(node): void

Defined in: src/sdk/components/common/LifecycleComponent.ts:52

A callback that is called after the component is rendered.

Parameters

ParameterTypeDescription
nodeVNodeThe component's VNode.

Returns

void

Overrides

DisplayComponent.onAfterRender


onBeforeRender()

onBeforeRender(): void

Defined in: src/sdk/components/FSComponent.ts:80

A callback that is called before the component is rendered.

Returns

void

Inherited from

DisplayComponent.onBeforeRender


pause()

pause(): void

Defined in: src/sdk/components/common/LifecycleComponent.ts:31

Pauses subscriptions managed by the component lifecycle and the first LifecycleComponent of each child component branch.

Returns

void


register()

protected register<T>(sub): T

Defined in: src/sdk/components/common/LifecycleComponent.ts:62

Registers a subscription with the component default lifecycle.

Type Parameters

Type Parameter
T extends Subscription

Parameters

ParameterTypeDescription
subTThe subscription to register.

Returns

T

The registered subscription.


render()

abstract render(): null | VNode

Defined in: src/sdk/components/FSComponent.ts:93

Renders the component.

Returns

null | VNode

A JSX element to be rendered.

Inherited from

DisplayComponent.render


resume()

resume(): void

Defined in: src/sdk/components/common/LifecycleComponent.ts:37

Resumes subscriptions managed by the component lifecycle and the first LifecycleComponent of each child component branch.

Returns

void