Skip to content

Instantly share code, notes, and snippets.

View ziuniecki's full-sized avatar
👨‍💻

Wojciech Chociej ziuniecki

👨‍💻
View GitHub Profile
@ziuniecki
ziuniecki / decorator-with-params.ts
Last active January 30, 2019 19:43
Angular component custom decorator boilerplate with parameters
import {OnInit, Type} from '@angular/core';
/**
* Decorator with params for Angular components.
* InterfaceName is name of interface that declare required fields, which component should have.
* How to use:
* `
@DecoratorName(params)
@Component({
selector: 'app-example',
@JasonKleban
JasonKleban / LiteEvent.ts
Last active January 26, 2023 06:33
TypeScript LiteEvent Events implementation
interface ILiteEvent<T> {
on(handler: { (data?: T): void }) : void;
off(handler: { (data?: T): void }) : void;
}
class LiteEvent<T> implements ILiteEvent<T> {
private handlers: { (data?: T): void; }[] = [];
public on(handler: { (data?: T): void }) : void {
this.handlers.push(handler);