npm

Share private packages across your team with npm Orgs, now with simplified billing via the aws marketplace!Learn more »

@robotlegsjs/pixi-signalmediator

1.0.0 • Public • Published

RobotlegsJS Pixi SignalMediator Extension

GitHub license Gitter chat Build Status codebeat badge Test Coverage npm version Greenkeeper badge styled with prettier

A port of Robotlegs SignalMediator Extension to TypeScript.

Originally published on RobotlegsJS-SignalMediator.

Installation

You can get the latest release and the type definitions using NPM:

npm install @robotlegsjs/pixi-signalmediator

Or using Yarn:

yarn add @robotlegsjs/pixi-signalmediator

From version 0.2.0 of this package, the PixiJS dependencies were moved to peerDependencies, allowing the final user to choose the desired version of the pixi.js library on each project.

The @robotlegsjs/pixi-signalmediator package is compatible with versions between the >=4.2.1 <5 version range of pixi.js library.

Since each version of pixi.js library defines which version of eventemitter3 library is being used, remember to also install the proper version of eventemitter3 in your project.

As example, when you would like to use the version 4.2.1 of pixi.js library, you can run:

npm install pixi.js@4.2.1 eventemitter3@^2.0.0 reflect-metadata --save

or

yarn add pixi.js@4.2.1 eventemitter3@^2.0.0 reflect-metadata

Then follow the installation instructions of RobotlegsJS library to complete the setup of your project.

Dependencies

Peer Dependencies

Usage

import { inject, injectable } from "@robotlegsjs/core";
 
import { SignalMediator } from "@robotlegsjs/pixi-signalmediator";
 
@injectable()
export class MyUserMediator extends SignalMediator<MyUserView> {
 
    @inject(UserLoggedInSignal) protected userLoggedInSignal: UserLoggedInSignal;
    @inject(UserLoggedOutSignal) protected userLoggedOutSignal: UserLoggedOutSignal;
 
    constructor() {
        super();
    }
 
    private onUserLoggedIn(): void {
        // user is logged in, do something...
    }
 
    private onUserLoggedOut(): void {
        // user is logged out, do something...
    }
 
    public initialize(): void {
        this.addToSignal(this.userLoggedInSignal, this.onUserLoggedIn.bind(this));
        this.addToSignal(this.userLoggedOutSignal, this.onUserLoggedOut.bind(this));
    }
 
    public destroy(): void {
        // clean up memory...
    }
}

License

MIT

install

npm i @robotlegsjs/pixi-signalmediator

Downloadsweekly downloads

9

version

1.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
  • avatar
Report a vulnerability