Skip to content

Commit

Permalink
Remove unused evented from ListContent (#2621)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbieTheWagner authored Jan 21, 2025
1 parent f3b2de0 commit e0daadd
Showing 1 changed file with 0 additions and 53 deletions.
53 changes: 0 additions & 53 deletions app/components/list-content.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { action } from '@ember/object';
import { addListener, removeListener, sendEvent } from '@ember/object/events';
import { inject as service } from '@ember/service';
import Component from '@glimmer/component';
import { htmlSafe } from '@ember/template';
import { schedule } from '@ember/runloop';
import { tracked } from '@glimmer/tracking';
import type { AnyFn } from 'ember/-private/type-utils';

import type LayoutService from '../services/layout';

Expand Down Expand Up @@ -96,55 +94,4 @@ export default class ListContent extends Component<ListContentSignature> {
updateContentHeight(height: number) {
this.contentHeight = height;
}

// Manually implement Evented functionality, so we can move away from the mixin
// TODO: Do we even need any evented-like things in this component?

on(eventName: string, method: AnyFn): void;
on(eventName: string, target: unknown, method: AnyFn): void;

@action
on(eventName: string, targetOrMethod: unknown | AnyFn, method?: AnyFn): void {
if (typeof targetOrMethod === 'function') {
// If we did not pass a target, default to `this`
addListener(this, eventName, this, targetOrMethod as AnyFn);
} else {
addListener(this, eventName, targetOrMethod, method!);
}
}

one(eventName: string, method: AnyFn): void;
one(eventName: string, target: unknown, method: AnyFn): void;

@action
one(eventName: string, targetOrMethod: unknown | AnyFn, method?: AnyFn) {
if (typeof targetOrMethod === 'function') {
// If we did not pass a target, default to `this`
addListener(this, eventName, this, targetOrMethod as AnyFn, true);
} else {
addListener(this, eventName, targetOrMethod, method!, true);
}
}

off(eventName: string, method: AnyFn): void;
off(eventName: string, target: unknown, method: AnyFn): void;

@action
off(eventName: string, targetOrMethod: unknown | AnyFn, method?: AnyFn) {
try {
if (typeof targetOrMethod === 'function') {
// If we did not pass a target, default to `this`
removeListener(this, eventName, this, targetOrMethod as AnyFn);
} else {
removeListener(this, eventName, targetOrMethod, method!);
}
} catch (e) {
console.error(e);
}
}

@action
trigger(eventName: string, ...args: Array<any>) {
sendEvent(this, eventName, args);
}
}

0 comments on commit e0daadd

Please sign in to comment.