Stack Exchange
Angular custom event system
Hello guys am facing a problem with sharing data a cross multiple angular applications
shell-Application->home.component.ts:
import { MessageBusService } from 'shared-lib/src/lib/services/message-bus.service';
constructor(
        private messageBus:MessageBusService,
        ) {}
ngOnInit() {
this.messageBus.sendMessage({ text: 'Hello from Sender!' });
}


message-bus.service.ts:

@Injectable({
  providedIn: 'root'
})
export class MessageBusService {
  private messageSource = new BehaviorSubject<any>(null);
  currentMessage = this.messageSource.asObservable();
  msgstring:any;


  constructor() {}

  sendMessage(message: any) {
    console.log("sending:", message);
    this.messageSource.next(message); 
    this.currentMessage.subscribe(message => this.msgstring = message);
  }
  
  getmsgstring(){
    return this.msgstring;
  }
  clearMessage() {
    this.messageSource.next(null); 
  }  
}


microfrontend->list.component.ts:
import { MessageBusService } from 'shared-lib/src/lib/services/message-bus.service';
 constructor(
        private messageBus:MessageBusService,
        ) { 
        
ngOnInit() {

        this.messageBus.currentMessage.subscribe(message => {
            if (message !== null) {
              this.message = message;
              console.log("rec msg:", this.message);
            } else {
              console.log("res msg is null");
            }
          }); 
       
        }
ngOnDestroy() {
          if (this.subscription) {
            this.subscription.unsubscribe();
          }
        }


i would be really really appricate your time and if u have a tipp for me dont hesitate
an object with the text proberty = Hello from Sender!
