Class SocketComponent<P, S, SS>

Component using Socket API for communication.

Type Parameters

  • P = {}
  • S = {}
  • SS = any

Hierarchy (view full)

Constructors

Properties

_mounted: boolean

Indicates if the component is mounted.

_socketRequest: SocketRequest

Methods

  • Calls the socket event.

    Type Parameters

    • R = any

    Parameters

    • event: string

      Name of the event.

    Returns Promise<R>

    R Type of response.

  • Calls the socket event.

    Type Parameters

    • P = any
    • R = any

    Parameters

    • event: string

      Name of the event.

    • data: P

      Event parameters.

    Returns Promise<R>

    P Type of parameters.

    R Type of response.

  • Calls the socket event.

    Type Parameters

    • P = any
    • R = any

    Parameters

    • event: string

      Name of the event.

    • data: P

      Event parameters.

    • timeout: number

      Timeout of the event.

    Returns Promise<R>

    P Type of parameters.

    R Type of response.

  • Calls the socket event.

    Type Parameters

    • P = any
    • R = any

    Parameters

    • event: string

      Name of the event.

    • data: P

      Event parameters.

    • timeout: number

      Timeout of the event.

    • onProgress: ((progress: number) => void)

      Function called in the progress tick.

        • (progress): void
        • Parameters

          • progress: number

          Returns void

    Returns Promise<R>

    P Type of parameters.

    R Type of response.

  • 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

  • Emits the socket event. The response can be handled in the on method.

    Parameters

    • event: string

      Name of the event.

    Returns this

    P Type of parameters.

  • Emits the socket event. The response can be handled in the on method.

    Parameters

    • event: string

      Name of the event.

    • key: string

      Socket event key.

    Returns this

  • Emits the socket event. The response can be handled in the on method.

    Type Parameters

    • P = any

    Parameters

    • event: string

      Name of the event.

    • key: string

      Socket event key.

    • data: P

      Event parameters.

    Returns this

    P Type of parameters.

  • Emits the socket event. The response can be handled in the on method.

    Type Parameters

    • P = any

    Parameters

    • event: string

      Name of the event.

    • key: string

      Socket event key.

    • data: P

      Event parameters.

    • onProgress: ((progress: number) => void)

      Function called in the progress tick.

        • (progress): void
        • Parameters

          • progress: number

          Returns void

    Returns this

    P Type of parameters.

  • Gets a list of events that are registered in on method after the component mount and saves the data to the component state.

    Returns {
        data?: {
            [key: string]: any;
        };
        emit?: boolean;
        name: string;
        state: keyof S;
    }[]

  • Gets the text from the dictionary as JSX object. All HTML in the text is converted to JSX.

    Type Parameters

    • T = any

    Parameters

    • key: keyof T

      Key of the text in the dictionary.

    Returns Element

    T - Type of the dictionary object -> typeof { key: 'value' }.

  • Gets the text from the dictionary as JSX object. All HTML in the text is converted to JSX.

    Type Parameters

    • T = any

    Parameters

    • key: keyof T

      Key of the text in the dictionary.

    • Rest...args: any[]

      Arguments for text format.

    Returns Element

    T - Type of the dictionary object -> typeof { key: 'value' }.

  • Gets the state key of the component instance. By default the method returns null. If it's overriden to return a string value the saveState and loadState are handled automatically in the component's lifecycle.

    Returns string

  • Gets the text from the dictionary.

    Type Parameters

    • T = any

    Parameters

    • key: keyof T

      Key of the text in the dictionary.

    Returns string

    T - Type of the dictionary object -> typeof { key: 'value' }.

  • Gets the text from the dictionary.

    Type Parameters

    • T = any

    Parameters

    • key: keyof T

      Key of the text in the dictionary.

    • Rest...args: any[]

      Arguments for text format.

    Returns string

    T - Type of the dictionary object -> typeof { key: 'value' }.

  • Loads the state from the memory storage.

    Parameters

    • key: string

      State key of the component instance.

    Returns Promise<void>

  • Registers socket event listener. This method should be called in componentDidMount.

    Type Parameters

    • R = any

    Parameters

    • event: string

      Name of the event.

    • callback: ((error?: any, data?: R) => void)

      Callback for the event.

        • (error?, data?): void
        • Parameters

          • Optionalerror: any
          • Optionaldata: R

          Returns void

    Returns this

  • Called if some socket error appears.

    Parameters

    • error: any

      Socket error.

    Returns void

  • Called if the socket changes its state.

    Parameters

    Returns void

  • Calls the socket event.

    Type Parameters

    • R = any

    Parameters

    • event: string

      Name of the event.

    • callback: ((error?: any, data?: R) => void)

      Callback function.

        • (error?, data?): void
        • Parameters

          • Optionalerror: any
          • Optionaldata: R

          Returns void

    Returns this

    R Type of response.

  • Calls the socket event.

    Type Parameters

    • P = any
    • R = any

    Parameters

    • event: string

      Name of the event.

    • data: P

      Event parameters.

    • callback: ((error?: any, data?: R) => void)

      Callback function.

        • (error?, data?): void
        • Parameters

          • Optionalerror: any
          • Optionaldata: R

          Returns void

    Returns this

    P Type of parameters.

    R Type of response.

  • Calls the socket event.

    Type Parameters

    • P = any
    • R = any

    Parameters

    • event: string

      Name of the event.

    • data: P

      Event parameters.

    • timeout: number

      Timeout of the event.

    • callback: ((error?: any, data?: R) => void)

      Callback function.

        • (error?, data?): void
        • Parameters

          • Optionalerror: any
          • Optionaldata: R

          Returns void

    Returns this

    P Type of parameters.

    R Type of response.

  • Calls the socket event.

    Type Parameters

    • P = any
    • R = any

    Parameters

    • event: string

      Name of the event.

    • data: P

      Event parameters.

    • timeout: number

      Timeout of the event.

    • callback: ((error?: any, data?: R) => void)

      Callback function.

        • (error?, data?): void
        • Parameters

          • Optionalerror: any
          • Optionaldata: R

          Returns void

    • onProgress: ((progress: number) => void)

      Function called in the progress tick.

        • (progress): void
        • Parameters

          • progress: number

          Returns void

    Returns this

    P Type of parameters.

    R Type of response.

  • Calls the socket event.

    Type Parameters

    • R = any

    Parameters

    • event: string

      Name of the event.

    Returns Promise<R>

    R Type of response.

  • Calls the socket event.

    Type Parameters

    • P = any
    • R = any

    Parameters

    • event: string

      Name of the event.

    • data: P

      Event parameters.

    Returns Promise<R>

    P Type of parameters.

    R Type of response.

  • Calls the socket event.

    Type Parameters

    • P = any
    • R = any

    Parameters

    • event: string

      Name of the event.

    • data: P

      Event parameters.

    • timeout: number

      Timeout of the event.

    Returns Promise<R>

    P Type of parameters.

    R Type of response.

  • Calls the socket event.

    Type Parameters

    • P = any
    • R = any

    Parameters

    • event: string

      Name of the event.

    • data: P

      Event parameters.

    • timeout: number

      Timeout of the event.

    • onProgress: ((progress: number) => void)

      Function called in the progress tick.

        • (progress): void
        • Parameters

          • progress: number

          Returns void

    Returns Promise<R>

    P Type of parameters.

    R Type of response.

  • Saves the current state to the memory storage.

    Parameters

    • key: string

      State key of the component instance.

    Returns void