@paperbits/common
Version:
Paperbits common components.
18 lines (15 loc) • 625 B
text/typescript
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);
}
};
}
}