Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ModuleScreen Abstract

An abstract class to be inherited on screen component class of the Module package. Screen component is an executable unit on DART-Platform. Conceptually,the components are like React functions. They accept arbitrary inputs (called “props”) and return React elements describing what should appear on the screen.

This component has a lifecycle. For more information on each lifecycle, see React.Component's lifecycle.


constructor()

render()

componentDidMount()

shouldComponentUpdate()

componentDidUpdate()

onBind()

onUnbind()

componentWillUnmount()

typeparam S

An type params to describe a React.Component's state object.

api-version

1

user

Hierarchy

Index

Constructors

Properties

context: any

If using the new style context, re-declare this in your class to be the React.ContextType of your static contextType. Should be used with type annotation or static contextType.

static contextType = MyContext
// For TS pre-3.7:
context!: React.ContextType<typeof MyContext>
// For TS 3.7 and above:
declare context: React.ContextType<typeof MyContext>
see

https://react.dev/reference/react/Component#context

message: Message

An object that is requested to execute the screen component. It is initialized in constructor through props.

api-version

1

user
messenger: IModuleMessenger

An instance of IModuleMessenger for communication between components rendered on the same screen. It is initialized in constructor through props.

api-version

1

user
moduleContext: ModuleContext

An object that is described about an environment of the screen component. It is initialized in constructor through props.

api-version

1

user
props: Readonly<ModuleScreenProps> & Readonly<{ children?: ReactNode }>
refs: {}

Type declaration

  • [key: string]: ReactInstance
screenInterface: IModuleScreenInterface

An interface to interact with screen.

api-version

1

system
state: Readonly<any>
systemTheme: any

An object to apply system theme on the screen component.

import { ThemeProvider } from "@mui/material/styles";
...

class MainScreen extends ModuleScreen {

...

render() {
return(
<ThemeProvider theme={this.systemTheme}>
...
</ThemeProvider>
);
}
}
api-version

1

user
contextType?: Context<any>

If set, this.context will be set at runtime to the current value of the given Context.

Usage:

type MyContext = number
const Ctx = React.createContext<MyContext>(0)

class Foo extends React.Component {
static contextType = Ctx
context!: React.ContextType<typeof Ctx>
render () {
return <>My context's value: {this.context}</>;
}
}
see

https://react.dev/reference/react/Component#static-contexttype

Methods

  • UNSAFE_componentWillMount(): void
  • UNSAFE_componentWillReceiveProps(nextProps: Readonly<ModuleScreenProps>, nextContext: any): void
  • UNSAFE_componentWillUpdate(nextProps: Readonly<ModuleScreenProps>, nextState: Readonly<any>, nextContext: any): void
  • componentDidCatch(error: Error, errorInfo: ErrorInfo): void
  • Catches exceptions generated in descendant components. Unhandled exceptions will cause the entire component tree to unmount.

    Parameters

    • error: Error
    • errorInfo: ErrorInfo

    Returns void

  • componentDidMount(): void
  • Called immediately after a component is mounted. Setting state here will trigger re-rendering.

    Returns void

  • componentDidUpdate(prevProps: Readonly<ModuleScreenProps>, prevState: Readonly<any>, snapshot?: any): void
  • Called immediately after updating occurs. Not called for the initial render.

    The snapshot is only present if getSnapshotBeforeUpdate is present and returns non-null.

    Parameters

    Returns void

  • componentWillMount(): void
  • componentWillReceiveProps(nextProps: Readonly<ModuleScreenProps>, nextContext: any): void
  • componentWillUnmount(): void
  • Called immediately before a component is destroyed. Perform any necessary cleanup in this method, such as cancelled network requests, or cleaning up any DOM elements created in componentDidMount.

    Returns void

  • componentWillUpdate(nextProps: Readonly<ModuleScreenProps>, nextState: Readonly<any>, nextContext: any): void
  • forceUpdate(callback?: (() => void)): void
  • Parameters

    • Optional callback: (() => void)
        • (): void
        • Returns void

    Returns void

  • getSnapshotBeforeUpdate(prevProps: Readonly<ModuleScreenProps>, prevState: Readonly<any>): any
  • Runs before React applies the result of render to the document, and returns an object to be given to componentDidUpdate. Useful for saving things such as scroll position before render causes changes to it.

    Note: the presence of getSnapshotBeforeUpdate prevents any of the deprecated lifecycle events from running.

    Parameters

    Returns any

  • isScreenFocused(): boolean
  • Whether the screen is focused or not.

    api-version

    1

    user

    Returns boolean

    Return true if the screen is focused or not.

  • isScreenVisible(): boolean
  • Whether the screen is visible or not. In the case of a PopupScreen, it is not focused, but can be seen.

    api-version

    1

    user

    Returns boolean

    Return true if the screen is visible or not.

  • Called when a client has been bound to this screen component.

    api-version

    1

    system

    Parameters

    Returns boolean

    Return true if you implemented events on the IModuleChannel which is sent as parameter. May return false if the screen component doesn't support interface about the message.

  • onDataSynchronized(): void
  • Called when the module's data have been synchronized. When Dart-Platform gets control, it initializes the Dart-Platform's system and modules internal data to the data that is synchronized with the Controller.

    api-version

    1

    system

    Returns void

  • onNewMessage(message: Message): Promise<boolean>
  • Override to handle new message which has been sent by system. Should not be call super method:

    onNewMessage(message: Message) {
    // super.onNewMessage(message); <-- do not call super method

    // implement here to handle the new message
    }
    api-version

    1

    system

    Parameters

    Returns Promise<boolean>

    Return true if the message has been handled, otherwise false.

  • onScreenFocused(focused: boolean): void
  • Called when screen's focus state has been changed.

    api-version

    1

    system

    Parameters

    • focused: boolean

      A focused state.

    Returns void

  • onScreenVisible(visible: boolean): void
  • Called when screen's visible state has been changed.

    api-version

    2

    system

    Parameters

    • visible: boolean

      A visible state.

    Returns void

  • Called when a client has been unbound from this screen component.

    api-version

    1

    system

    Parameters

    • message: Message

      A Message the was used to bind to this screen component.

    Returns void

  • render(): ReactNode
  • Returns ReactNode

  • setState<K>(state: any, callback?: (() => void)): void
  • Type Parameters

    • K extends string | number | symbol

    Parameters

    • state: any
    • Optional callback: (() => void)
        • (): void
        • Returns void

    Returns void

  • shouldComponentUpdate(nextProps: Readonly<ModuleScreenProps>, nextState: Readonly<any>, nextContext: any): boolean
  • Called to determine whether the change in props and state should trigger a re-render.

    Component always returns true. PureComponent implements a shallow comparison on props and state and returns true if any props or states have changed.

    If false is returned, Component#render, componentWillUpdate and componentDidUpdate will not be called.

    Parameters

    Returns boolean

Generated using TypeDoc