Skip to content

Commit

Permalink
use IEventEmitterMap to handle view events since pixi view are extend…
Browse files Browse the repository at this point in the history
…ing eventemitter3
  • Loading branch information
tiagoschenkel committed May 11, 2022
1 parent 5618787 commit 233ac06
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 117 deletions.
2 changes: 2 additions & 0 deletions packages/pixi/src/robotlegs/bender/bundles/pixi/PixiBundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// ------------------------------------------------------------------------------

import { IBundle, IContext, ILogger, instanceOfType } from "@robotlegsjs/core";
import { LocalEventEmitterMapExtension } from "@robotlegsjs/eventemitter3";
import { IContextView } from "../../extensions/contextView/api/IContextView";
import { ContextViewExtension } from "../../extensions/contextView/ContextViewExtension";
import { ContextView } from "../../extensions/contextView/impl/ContextView";
Expand Down Expand Up @@ -41,6 +42,7 @@ export class PixiBundle implements IBundle {
this._logger = context.getLogger(this);

this._context.install(
LocalEventEmitterMapExtension,
ContextViewExtension,
ViewManagerExtension,
StageObserverExtension,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,10 @@
// in accordance with the terms of the license agreement accompanying it.
// ------------------------------------------------------------------------------

import {
Event,
IClass,
IEvent,
IEventDispatcher,
IEventMap,
inject,
injectable
} from "@robotlegsjs/core";
import { DisplayObject } from "pixi.js";
import { Event, IClass, IEvent, IEventDispatcher, inject, injectable } from "@robotlegsjs/core";
import { IEventEmitterMap } from "@robotlegsjs/eventemitter3";
import { DisplayObject, utils } from "pixi.js";
import { IMediator } from "../api/IMediator";
import { ConvertToEventDispatcher } from "./ConvertToEventDispatcher";

/**
* Classic Robotlegs mediator implementation
Expand All @@ -25,18 +17,12 @@ import { ConvertToEventDispatcher } from "./ConvertToEventDispatcher";
*/
@injectable()
export abstract class Mediator<T extends DisplayObject> implements IMediator {
/*============================================================================*/
/* Private Properties */
/*============================================================================*/

private _viewConverted: ConvertToEventDispatcher;

/*============================================================================*/
/* Protected Properties */
/*============================================================================*/

@inject(IEventMap)
protected eventMap: IEventMap;
@inject(IEventEmitterMap)
protected eventMap: IEventEmitterMap;

@inject(IEventDispatcher)
protected eventDispatcher: IEventDispatcher;
Expand All @@ -49,7 +35,6 @@ export abstract class Mediator<T extends DisplayObject> implements IMediator {

public set view(view: T) {
this._viewComponent = view;
this._viewConverted = new ConvertToEventDispatcher(this._viewComponent);
}

public get view(): T {
Expand Down Expand Up @@ -84,21 +69,10 @@ export abstract class Mediator<T extends DisplayObject> implements IMediator {

protected addViewListener(
eventString: string,
listener: Function,
thisObject?: any,
eventClass?: IClass<IEvent>,
useCapture?: boolean,
priority?: number
listener: utils.EventEmitter.ListenerFn,
thisObject?: any
): void {
this.eventMap.mapListener(
this._viewConverted,
eventString,
listener,
thisObject,
eventClass,
useCapture,
priority
);
this.eventMap.on(this._viewComponent, eventString, listener, thisObject);
}

protected addContextListener(
Expand Down Expand Up @@ -131,19 +105,10 @@ export abstract class Mediator<T extends DisplayObject> implements IMediator {

protected removeViewListener(
eventString: string,
listener: Function,
thisObject?: any,
eventClass?: IClass<IEvent>,
useCapture?: boolean
listener: utils.EventEmitter.ListenerFn,
thisObject?: any
): void {
this.eventMap.unmapListener(
this._viewConverted,
eventString,
listener,
thisObject,
eventClass,
useCapture
);
this.eventMap.off(this._viewComponent, eventString, listener, thisObject);
}

protected removeContextListener(
Expand Down

0 comments on commit 233ac06

Please sign in to comment.