How to use @robotlegsjs/core - 10 common examples

To help you get started, we’ve selected a few @robotlegsjs/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RobotlegsJS / RobotlegsJS-Pixi / test / robotlegs / bender / extensions / mediatorMap / support / HookWithMediatorAndViewInjectionReportFunction.ts View on Github external
//  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);
    }
}
github RobotlegsJS / RobotlegsJS-Pixi / test / robotlegs / bender / extensions / mediatorMap / support / ExampleMediator2.ts View on Github external
//  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");
    }
}
github RobotlegsJS / RobotlegsJS-Pixi / test / robotlegs / bender / extensions / mediatorMap / support / ExampleDisplayObjectMediator.ts View on Github external
// ------------------------------------------------------------------------------
//  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");
    }
}
github RobotlegsJS / RobotlegsJS-Pixi / test / robotlegs / bender / extensions / mediatorMap / support / OnlyIfViewHasChildrenGuard.ts View on Github external
// ------------------------------------------------------------------------------
//  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;
    }
}
github RobotlegsJS / RobotlegsJS-Pixi / test / robotlegs / bender / extensions / mediatorMap / support / ExampleMediator.ts View on Github external
// ------------------------------------------------------------------------------
//  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");
    }
}
github RobotlegsJS / RobotlegsJS-Pixi / test / robotlegs / bender / extensions / mediatorMap / support / GrumpyGuard.ts View on Github external
// ------------------------------------------------------------------------------
//  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;
    }
}
github RobotlegsJS / RobotlegsJS-Pixi / test / robotlegs / bender / extensions / mediatorMap / support / NullMediator.ts View on Github external
// ------------------------------------------------------------------------------
//  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 {}
github RobotlegsJS / RobotlegsJS-Pixi / test / robotlegs / bender / extensions / mediatorMap / support / NullMediator2.ts View on Github external
// ------------------------------------------------------------------------------
//  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 {}
github RobotlegsJS / RobotlegsJS-Pixi / test / robotlegs / bender / extensions / mediatorMap / support / HappyGuard.ts View on Github external
// ------------------------------------------------------------------------------
//  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;
    }
}
github RobotlegsJS / RobotlegsJS-Pixi / test / robotlegs / bender / extensions / mediatorMap / support / RectangleMediator.ts View on Github external
// ------------------------------------------------------------------------------
//  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;
}

@robotlegsjs/core

An architecture-based IoC framework for JavaScript/TypeScript

MIT
Latest version published 2 years ago

Package Health Score

49 / 100
Full package analysis