I am trying to use the Microservices Architechture in my app, but am a little confused about the front-end integration. Here is my configuration:
PHP Server -> serving Main HTML application page containing embedded Web Component (Custom HTML Element)
Python Server -> serving the Embedded Web Component and related data
How do I include the Embedded Web Component (which resides in an HTML file) in my main web page? HTML imports will be deprecated as of Feb 2020, and AFAIK ES6 imports allow you to only import js files?
Here is the basic code for my embedded custom web component:
<template id="algo-box-template">
<slot name="algo-chart"></slot>
<slot name="algo-messages"></slot>
</template>
<script src="./highstock.js"></script>
<script type="module">
import AlgoChart from "/js/algochart.js";
customElements.define('algo-box',
class extends HTMLElement {
connectedCallback() {
var template = document
.getElementById('algo-box-template')
.content;
const shadowRoot = this.attachShadow({mode: 'open'})
.appendChild(template.cloneNode(true));
var data = fetch("http://xx.xx.xx.xx/some_path/some_url_parameter")
.then((response) => { response.json().then((data) => { this.childNodes[0].nextElementSibling.d = data; });});
}
}
);
</script>
<algo-box class="algo-box">
<algo-chart slot="algo-chart" />
<algo-messages slot="algo-messages" />
</algo-box>
What import statement do I have to use in my Main HTML application so that I can put the algo-box tag/component in my Main HTML page? Am I missing something basic? Or am I approaching this in the wrong way?
Any help would be appreciated. Thanks in advance.