Introduce MiniMessage rendering system for structured chat formatting and interaction
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Subject } from 'rxjs';
|
||||
import { MiniMessageClickPayload } from './mini-message.types';
|
||||
|
||||
/**
|
||||
* Because <mini-message> renders itself recursively for `extra` children, a plain
|
||||
* @Output() would need to be manually re-emitted at every level. Instead, every
|
||||
* instance injects this single service (provided once at the root usage) and pushes
|
||||
* clicks through it. Subscribe to `clicks$` wherever you render the top-level component.
|
||||
*/
|
||||
@Injectable()
|
||||
export class MiniMessageInteractionService {
|
||||
private readonly clickSubject = new Subject<MiniMessageClickPayload>();
|
||||
readonly clicks$ = this.clickSubject.asObservable();
|
||||
|
||||
emitClick(payload: MiniMessageClickPayload): void {
|
||||
this.clickSubject.next(payload);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user