Class: Module<Events>

moralis-monorepo / @moralisweb3/core / Module

Class: Module<Events>

@moralisweb3/core.Module

The base class of every Moralis class that gets registered as a module via MoralisModules
It should always be created with:

  • name: name of the module (should be unique)
  • core: the MoralisCore instance
  • type: (optional) CoreModuleType, defaults to CoreModuleType.DEFAULT

When creating an api, or network module, you should use the ApiModule or NetworkModule

Type parameters

NameType
Eventsextends EventMap = any

Hierarchy

Table of contents

Methods

Methods

start

Abstract start(): void | Promise<void>

Start the module (if needed).
This function can be used to initialize variables etc.

Returns

void | Promise<void>


cleanUp

cleanUp(): void

Any cleanup that needs to be done for removing this module.
It also should remove the module via this.core.modules.remove(this.name)

Returns

void


listen

listen<Event>(eventName, listener): () => TypedEventEmitter<Events>

Listen to an event, and returns a cleanup function

Type parameters

NameType
Eventextends string | number | symbol

Parameters

NameType
eventNameEvent
listenerEvents[Event]

Returns

fn

▸ (): TypedEventEmitter<Events>

Returns

TypedEventEmitter<Events>


Did this page help you?