Perspective Component Handling Message

I'm writing my first Perspective component that will be receiving messages from the gateway, and I just wanted to confirm my understanding on the javascript side.

I've written a ComponentStoreDelegate:

export class MaterialTreeMessageHandler extends ComponentStoreDelegate {
	handleEvent(eventName: string, eventObject: JsObject): void {
		console.log('handling event', eventName, eventObject);
		this.notify();
	}
}

Then in my component I can subscribe with:

	props.store.delegate?.subscribe(() => {
		console.log("message received");
	})

To pass the actual message data, am I supposed to be implementing mapStateToProps in the message delegate and then directly accessing it via:

props.store.delegate.myPropertyName

Also, is there a difference between props.delegate and props.store.delegate?

Am I understanding this correctly? I have something that sort of works, but wanted to make sure this is the "intended' usage...

I looked at this a bit, but quickly ran out of time and knowledge. I don't see anything readily wrong with what you're doing.

From what I can tell, implementing this is entirely optional.

I don't think so.

1 Like

Awesome - thank you for taking the time to respond!