Skip to main content
Version: Next

Class: Component<S>

molecule.react.Component

Type parameters​

NameType
Sany

Hierarchy​

Implements​

Constructors​

constructor​

• new Component<S>()

Type parameters​

NameType
Sany

Overrides​

GlobalEvent.constructor

Defined in​

react/component.ts:47

Properties​

_event​

• Private _event: EventEmitter

Defined in​

react/component.ts:45


state​

• Protected Abstract state: S

Defined in​

react/component.ts:44

Methods​

count​

▸ count(name): number

Count the service event

Parameters​

NameTypeDescription
namestringEvent name

Returns​

number

Inherited from​

GlobalEvent.count

Defined in​

common/event/eventBus.ts:28


emit​

▸ emit(name, ...args): void

Emit the service event

Parameters​

NameTypeDescription
namestringEvent name
...argsanyArguments

Returns​

void

Inherited from​

GlobalEvent.emit

Defined in​

common/event/eventBus.ts:20


forceUpdate​

▸ forceUpdate(): void

Force to update the Component

Returns​

void

Implementation of​

IComponent.forceUpdate

Defined in​

react/component.ts:81


getState​

▸ getState(): S

Get the Component state

Returns​

S

Implementation of​

IComponent.getState

Defined in​

react/component.ts:85


onUpdateState​

▸ onUpdateState(listener): void

Listen to the Component state update event

Parameters​

NameType
listener(prevState: S, nextState: S) => void

Returns​

void

Implementation of​

IComponent.onUpdateState

Defined in​

react/component.ts:73


removeOnUpdateState​

▸ removeOnUpdateState(listener?): void

Remove the Component update event listening, default is remove all, also you can remove one by pass the listener

Parameters​

NameType
listener?Function

Returns​

void

Implementation of​

IComponent.removeOnUpdateState

Defined in​

react/component.ts:77


render​

▸ render(nextState?): void

Initiative notify the component to render the view by the state

Parameters​

NameType
nextState?S

Returns​

void

Implementation of​

IComponent.render

Defined in​

react/component.ts:69


setState​

▸ setState(values, callback?): void

Set the state values, and notify the view component to re render

Parameters​

NameTypeDescription
valuesPartial<S>update target state values
callback?(prevState: S, nextState: S) => void-

Returns​

void

Implementation of​

IComponent.setState

Defined in​

react/component.ts:56


subscribe​

▸ subscribe(name, listener): void

Subscribe the service event

Parameters​

NameTypeDescription
namestring | string[]Event name
listenerFunctionListener function

Returns​

void

Inherited from​

GlobalEvent.subscribe

Defined in​

common/event/eventBus.ts:11


unsubscribe​

▸ unsubscribe(name, listener?): void

Unsubscribe the specific event and the listener function

Parameters​

NameTypeDescription
nameanyThe event name
listener?Functionoptional, it unsubscribes events via name if not pass the listener function

Returns​

void

Inherited from​

GlobalEvent.unsubscribe

Defined in​

common/event/eventBus.ts:37