Been trawling Google for who knows how long and I can’t seem to find a solution to this. Hopefully someone can help
Let’s say I have a component containing two instances of a custom element, like this:
<template> <require from="my-custom-element"></require> <my-custom-element></my-custom-element> <!-- blah blah blah some more markup --> <my-custom-element></my-custom-element> </template.
Within the view-model for this custom element, I have an event aggregator subscription set up. The subscription is making an API call to a backend service.
Now, I’ve noticed that because I have two instances of the custom element injected into my component, that the API call is being made twice. This is not desirable.
How do I get these two custom elements to just share one view-model, and hence one subscription? Is that possible?