onValue not working in custom tile

I’m positive that there is some documentation somewhere that I’ve missed or this may have been addressed before. I’m trying to, when a variable has been updated, open up a dashboard from a custom tile:

<!-- Do not edit below -->
<script type="application/json" id="tile-settings">
{
  "schema": "0.2.0",
  "settings": [
    {
      "type": "VARIABLE",
      "name": "mapId",
      "label": "ID for which phone is being located",
      "filters": {"type": "String"}
    }
  ],
  "name": "iPhone Map Launcher"
}
</script>
<!-- Do not edit above -->

<script src="https://cdn.sharptools.io/js/custom-tiles/0.2.1/stio.js"></script>
<script src="https://cdn.sharptools.io/js/custom-tiles.js"></script>

<script>
    stio.ready(function(data){
        let mapId = data.settings.mapId;

        if (mapId) {
            console.log("mapId:", mapId);
            mapId.onValue(val => {
              	console.log("About to launch the dashboard using:" + val);
                window.parent.postMessage(
                    { action: "navigate", target: 'modal', dashboardId: '5cGNhMfOZZF7Jyw5eXVM' },
                    "*"
                );
            });
        } else {
            console.log("No mapId found.");
        }            
    });
</script>

When I put it in the dashboard and load it I can see that the variable mapId exists and that it gets written out to the console but it never goes within the onValue code block when that variable is changed:

Verify that the custom tile is set up properly with the variable

Clear the console, refresh the page, and confirm in the console that the variable is pulling in successfully

Change the variable to a different value

Return to the tab with the dashboard and confirm that onValue not triggering - console.log message not being displayed

These examples are all in Chrome but ultimiately I’ll be using Fully Kiosk for this.

Not sure if this will be of any value but here’s the screenshot of the worker:

I think I figured it out - I needed to remove the line above and it looks like it’s working.

Thanks for sharing your findings and fix!

Having both lines was effectively loading the stio Custom Tile library twice which was likely causing a conflict.