Skip to content

A simple implement about "Observer Model'

License

Notifications You must be signed in to change notification settings

netcodejs/event

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@netcodejs/event User Guide

This is the TypeScript framework of the "observer model". It provides fewer but efficient interfaces, such as on, off and so on.

Installation

For npm:

$ npm install @netcodejs/event --save

For Yarn:

$ yarn add @netcodejs/event

Usage

For esmodule:

import { Event } from "@netcodejs/event"

For commonjs:

var Event = require("@netcodejs/event")

Simple Example

const event = new Event();

function logHelloWorld(author: string) {
    console.log("Hello, world. Author: " + author + ".");
}
event.on("hello", logHelloWorld);

event.emit("hello", "LittleMoi"); // It will log "Hello, world. Author: LittleMoi".
event.emit("hello", "netcodejs"); // Similaryly, "Hello, world. Author: netcodejs".
event.emit("hi"); // No throws, no things.

About

A simple implement about "Observer Model'

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published