Skip to content

es cqrs.Interface.EventStoreAsyncOptions

Sclable CI edited this page Oct 7, 2024 · 7 revisions

@sclable/nestjs-libs / es-cqrs / EventStoreAsyncOptions

Interface: EventStoreAsyncOptions

Asyncronous options for the event store

Example (useFactory): app.module.ts

@Module({
  imports: [
    ESCQRSModule.forRootAsync({
      inject: [GlobalOptionsProvider]
      useFactory: async (globalOptions: GlobalOptionsProvider) => {
        return await globalOptions.getEventStoreOptions()
      }
    }),
    MyModule,
  ]
})

Example (useClass / useExisting): app.module.ts

class OptionsFactory implements EventStoreOptionsFactory {
  public async createEventStoreOptions() {
    return { logging: true }
  }
}

@Module({
  imports: [
    ESCQRSModule.forRootAsync({
      useClass: OptionsFactory
    }),
    MyModule,
  ]
})

It is also possible to add additional imports for the options factory if the service required is in another module

Example (imports): app.module.ts

@Module({
  imports: [
    ESCQRSModule.forRootAsync({
      imports: [GlobalOptionsModule]
      inject: [GlobalOptionsProvider]
      useFactory: async (globalOptions: GlobalOptionsProvider) => {
        return await globalOptions.getEventStoreOptions()
      }
    }),
    MyModule,
  ]
})

Extends

  • Pick<ModuleMetadata, "imports">

Properties

inject?

optional inject: any[]

Defined in

packages/es-cqrs/src/event-store/event-store-options.ts:95


useClass?

optional useClass: Type<EventStoreOptionsFactory>

Defined in

packages/es-cqrs/src/event-store/event-store-options.ts:96


useExisting?

optional useExisting: Type<EventStoreOptionsFactory>

Defined in

packages/es-cqrs/src/event-store/event-store-options.ts:97


useFactory()?

optional useFactory: (...args) => EventStoreOptions | Promise<EventStoreOptions>

Parameters

• ...args: any[]

Returns

EventStoreOptions | Promise<EventStoreOptions>

Defined in

packages/es-cqrs/src/event-store/event-store-options.ts:99

Clone this wiki locally