Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
// ------------------------------------------------------------------------------
import { Sprite } from "pixi.js";
import { injectable, inject, named, IHook } from "@robotlegsjs/core";
import { RectangleMediator } from "./RectangleMediator";
@injectable()
export class HookWithMediatorAndViewInjectionReportFunction implements IHook {
@inject(RectangleMediator)
public mediator: RectangleMediator;
@inject(Sprite)
public view: Sprite;
@inject("Function")
@named("reportView")
public reportView: Function;
public hook(): void {
this.reportView(this.view, this.mediator.width, this.mediator.height);
}
}
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
// ------------------------------------------------------------------------------
import { injectable, inject } from "@robotlegsjs/core";
import { Sprite } from "pixi.js";
import { MediatorWatcher } from "./MediatorWatcher";
@injectable()
export class ExampleMediator2 {
@inject(MediatorWatcher)
public mediatorWatcher: MediatorWatcher;
@inject(Sprite)
public view: Sprite;
public initialize(): void {
this.mediatorWatcher.notify("ExampleMediator2");
}
public destroy(): void {
this.mediatorWatcher.notify("ExampleMediator2 destroy");
}
}
// ------------------------------------------------------------------------------
// Copyright (c) 2017-present, RobotlegsJS. All Rights Reserved.
//
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
// ------------------------------------------------------------------------------
import { injectable, inject } from "@robotlegsjs/core";
import { DisplayObject } from "pixi.js";
import { MediatorWatcher } from "./MediatorWatcher";
@injectable()
export class ExampleDisplayObjectMediator {
@inject(MediatorWatcher)
public mediatorWatcher: MediatorWatcher;
@inject(DisplayObject)
public view: DisplayObject;
public initialize(): void {
this.mediatorWatcher.notify("ExampleDisplayObjectMediator");
}
}
// ------------------------------------------------------------------------------
// Copyright (c) 2017-present, RobotlegsJS. All Rights Reserved.
//
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
// ------------------------------------------------------------------------------
import { Sprite } from "pixi.js";
import { injectable, inject, IGuard } from "@robotlegsjs/core";
@injectable()
export class OnlyIfViewHasChildrenGuard implements IGuard {
@inject(Sprite)
public view: Sprite;
public approve(): boolean {
return this.view.children.length > 0;
}
}
// ------------------------------------------------------------------------------
// Copyright (c) 2017-present, RobotlegsJS. All Rights Reserved.
//
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
// ------------------------------------------------------------------------------
import { injectable, inject } from "@robotlegsjs/core";
import { Sprite } from "pixi.js";
import { MediatorWatcher } from "./MediatorWatcher";
@injectable()
export class ExampleMediator {
@inject(MediatorWatcher)
public mediatorWatcher: MediatorWatcher;
@inject(Sprite)
public view: Sprite;
public initialize(): void {
this.mediatorWatcher.notify("ExampleMediator");
}
public destroy(): void {
this.mediatorWatcher.notify("ExampleMediator destroy");
}
}
// ------------------------------------------------------------------------------
// Copyright (c) 2017-present, RobotlegsJS. All Rights Reserved.
//
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
// ------------------------------------------------------------------------------
import { injectable, IGuard } from "@robotlegsjs/core";
@injectable()
export class GrumpyGuard implements IGuard {
public approve(): boolean {
return false;
}
}
// ------------------------------------------------------------------------------
// Copyright (c) 2017-present, RobotlegsJS. All Rights Reserved.
//
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
// ------------------------------------------------------------------------------
import { injectable } from "@robotlegsjs/core";
@injectable()
export class NullMediator {}
// ------------------------------------------------------------------------------
// Copyright (c) 2017-present, RobotlegsJS. All Rights Reserved.
//
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
// ------------------------------------------------------------------------------
import { injectable } from "@robotlegsjs/core";
@injectable()
export class NullMediator2 {}
// ------------------------------------------------------------------------------
// Copyright (c) 2017-present, RobotlegsJS. All Rights Reserved.
//
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
// ------------------------------------------------------------------------------
import { injectable, IGuard } from "@robotlegsjs/core";
@injectable()
export class HappyGuard implements IGuard {
public approve(): boolean {
return true;
}
}
// ------------------------------------------------------------------------------
// Copyright (c) 2017-present, RobotlegsJS. All Rights Reserved.
//
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
// ------------------------------------------------------------------------------
import { injectable, inject, named } from "@robotlegsjs/core";
@injectable()
export class RectangleMediator {
@inject(Number)
@named("width")
public width: number;
@inject(Number)
@named("height")
public height: number;
}