UNPKG

@paperbits/common

Version:
18 lines (15 loc) 625 B
import { EventManager, Events } from "../events"; import { BehaviorHandle } from "./behavior"; export class LiveAreaBehavior { public static attach(element: HTMLElement, eventManager: EventManager): BehaviorHandle { const notificationHandler = (notification: string) => { element.innerText = notification; }; eventManager.addEventListener(Events.NotificationRequest, notificationHandler); return { detach: () => { eventManager.removeEventListener(Events.NotificationRequest, notificationHandler); } }; } }