How to use the @robotlegsjs/core.injectable function in @robotlegsjs/core

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 / 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;
}
github RobotlegsJS / RobotlegsJS-Pixi / test / robotlegs / bender / extensions / mediatorMap / support / NotAViewMediator.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 { MediatorWatcher } from "./MediatorWatcher";
import { NotAView } from "./NotAView";

@injectable()
export class NotAViewMediator {
    @inject(MediatorWatcher)
    public mediatorWatcher: MediatorWatcher;

    @inject(NotAView)
    public view: NotAView;

    public initialize(): void {
        this.view.mediatorName = "NotAViewMediator";
        this.mediatorWatcher.notify("NotAViewMediator");
    }

    public destroy(): void {
        this.mediatorWatcher.notify("NotAViewMediator destroy");
    }
}
github RonaldoSetzer / GAME-Match3 / typescript-match3 / src / matchthree / mediators / GridFieldComponentMediator.ts View on Github external
import { TweenLite } from "gsap";
import { Sprite } from "pixi.js";

import { PixiSpritePool } from "../game/utils/PieceDisplayPool";
import { PieceUtils } from "../game/utils/PieceUtils";
import { GameEvent } from "./../events/GameEvent";
import { GameManager } from "./../game/managers/GameManager";
import { LevelModel } from "./../game/models/LevelModel";
import { PieceData } from "./../game/models/PieceData";
import { Tile } from "./../game/models/Tile";
import { TouchPhase } from "./../game/models/TouchPhase";
import { AnimationUtils } from "./../game/utils/AnimationUtils";
import { GameService } from "./../services/GameService";
import { GridFieldComponent } from "./../views/components/GridFieldComponent";

@injectable()
export class GridFieldComponentMediator extends Mediator {
    @inject(LevelModel) private levelModel: LevelModel;
    @inject(GameManager) private gameManager: GameManager;
    @inject(GameService) private gameService: GameService;

    private _displays: Map;

    public initialize(): void {
        this._displays = new Map();
        this.view.generateGrid(this.levelModel.maxCols, this.levelModel.maxRows);

        this.view.interactive = true;

        this.eventMap.mapListener(this.eventDispatcher, GameEvent.CLEAR_GRID, this.game_onClearGridHandler, this);
        this.eventMap.mapListener(this.eventDispatcher, GameEvent.UPDATE_GRID, this.game_onUpdateGridHandler, this);
github RonaldoSetzer / GAME-Tetris / typescript-tetris / src / mediators / GameViewMediator.ts View on Github external
import { inject, injectable } from "@robotlegsjs/core";
import { Mediator } from "@robotlegsjs/pixi";

import { GameService } from "./../services/GameService";
import { GameView } from "./../views/GameView";

@injectable()
export class GameViewMediator extends Mediator {
    @inject(GameService) private gameService: GameService;

    public initialize(): void {
        this.view.createComponents();

        this.gameService.createLevel();
    }
    public destroy(): void {
        this.view.destroy();
    }
}
github RonaldoSetzer / GAME-Tetris / typescript-tetris / src / managers / GameManager.ts View on Github external
import { inject, injectable } from "@robotlegsjs/core";

import { Grid } from "../models/Grid";
import { TileGroup } from "../models/TileGroup";
import { GameService } from "../services/GameService";
import { Tile } from "./../models/Tile";

@injectable()
export class GameManager {
    @inject(GameService) private gameService: GameService;

    private _grid: Grid;
    private _currentPiece: TileGroup;
    private _tilesToUpdate: Tile[];
    private _tilesToRemove: Tile[];

    public createEmpytGrid(cols = 10, rows = 20): void {
        this._grid = new Grid(cols, rows);
        this._tilesToUpdate = new Array();
        this._tilesToRemove = new Array();
    }
    public addPiece(currentPiece: TileGroup): void {
        this._currentPiece = currentPiece;
        this._currentPiece.moveHorizontal(4);

@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