Add debugging option to make bus warnings throw Error; bump version

This commit is contained in:
Garrett Mills 2022-03-30 17:24:45 -05:00
parent 467721f775
commit dbe48ea8a5
3 changed files with 9 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@extollo/lib", "name": "@extollo/lib",
"version": "0.9.6", "version": "0.9.7",
"description": "The framework library that lifts up your code.", "description": "The framework library that lifts up your code.",
"main": "lib/index.js", "main": "lib/index.js",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",

View File

@ -8,7 +8,7 @@ import {
EventHandlerReturn, EventHandlerReturn,
EventHandlerSubscription, EventHandlerSubscription,
} from './types' } from './types'
import {Awaitable, Collection, Pipeline, uuid4} from '../../util' import {Awaitable, Collection, ifDebugging, Pipeline, uuid4} from '../../util'
import {Logging} from '../../service/Logging' import {Logging} from '../../service/Logging'
import {Unit} from '../../lifecycle/Unit' import {Unit} from '../../lifecycle/Unit'
import {Config} from '../../service/Config' import {Config} from '../../service/Config'
@ -185,6 +185,9 @@ export class Bus<TEvent extends Event = Event> extends Unit implements EventBus<
async up(): Promise<void> { async up(): Promise<void> {
if ( this.isUp ) { if ( this.isUp ) {
this.logging.warn('Attempted to boot more than once. Skipping.') this.logging.warn('Attempted to boot more than once. Skipping.')
ifDebugging('extollo.bus', () => {
throw new Error('Attempted to boot more than once. Skipping.')
})
return return
} }

View File

@ -1,6 +1,6 @@
import {Inject, Injectable, StaticInstantiable} from '../../di' import {Inject, Injectable, StaticInstantiable} from '../../di'
import {BusSubscriber, Event, EventBus, EventHandler, EventHandlerReturn, EventHandlerSubscription} from './types' import {BusSubscriber, Event, EventBus, EventHandler, EventHandlerReturn, EventHandlerSubscription} from './types'
import {Awaitable, Collection, Pipeline, uuid4} from '../../util' import {Awaitable, Collection, ifDebugging, Pipeline, uuid4} from '../../util'
import {Logging} from '../../service/Logging' import {Logging} from '../../service/Logging'
import {Bus, BusInternalSubscription} from './Bus' import {Bus, BusInternalSubscription} from './Bus'
import {getEventName} from './getEventName' import {getEventName} from './getEventName'
@ -109,6 +109,9 @@ export class LocalBus<TEvent extends Event = Event> extends CanonicalItemClass i
async up(): Promise<void> { async up(): Promise<void> {
if ( this.isUp ) { if ( this.isUp ) {
this.logging.warn('Attempted to boot more than once. Skipping.') this.logging.warn('Attempted to boot more than once. Skipping.')
ifDebugging('extollo.bus', () => {
throw new Error('Attempted to boot more than once. Skipping.')
})
return return
} }