Skip to content

Commit

Permalink
refractor: move the change to the parent (executeModule)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benzo-Fury committed Oct 6, 2023
1 parent a96c8bc commit 4beee4a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/handlers/event-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
MonoTypeOperatorFunction,
catchError,
finalize,
mergeMap
} from 'rxjs';
import {
Files,
Expand Down Expand Up @@ -149,8 +150,8 @@ export function executeModule(
) {
return of(module).pipe(
//converting the task into a promise so rxjs can resolve the Awaitable properly
concatMap(() => Result.wrapAsync(async () => task())),
concatMap(result => {
mergeMap(() => Result.wrapAsync(async () => task())),
mergeMap(result => {
if (result.isOk()) {
emitter.emit('module.activate', SernEmitter.success(module));
return EMPTY;
Expand Down
4 changes: 2 additions & 2 deletions src/handlers/interaction-event.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Interaction } from 'discord.js';
import { mergeMap, merge } from 'rxjs';
import { concatMap, merge } from 'rxjs';
import { SernEmitter } from '../core';
import {
isAutocomplete,
Expand Down Expand Up @@ -28,6 +28,6 @@ export function interactionHandler([emitter, , , modules, client]: DependencyLis
filterTap(e => emitter.emit('warning', SernEmitter.warning(e))),
makeModuleExecutor(module =>
emitter.emit('module.activate', SernEmitter.failure(module, SernError.PluginFailure))),
mergeMap(payload => executeModule(emitter, payload)),
concatMap(payload => executeModule(emitter, payload)),
);
}
4 changes: 2 additions & 2 deletions src/handlers/message-event.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mergeMap, EMPTY } from 'rxjs';
import { concatMap, EMPTY } from 'rxjs';
import type { Message } from 'discord.js';
import { SernEmitter } from '../core';
import { sharedEventStream, SernError, filterTap } from '../core/_internal';
Expand Down Expand Up @@ -42,6 +42,6 @@ export function messageHandler(
makeModuleExecutor(module => {
emitter.emit('module.activate', SernEmitter.failure(module, SernError.PluginFailure));
}),
mergeMap(payload => executeModule(emitter, payload)),
concatMap(payload => executeModule(emitter, payload)),
);
}

0 comments on commit 4beee4a

Please sign in to comment.