HEX
Server: Apache
System: Linux p3plzcpnl506847.prod.phx3.secureserver.net 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: slfopp7cb1df (5698090)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //home/slfopp7cb1df/public_html/sitepacket.com/src/client/src/api/hooks.js
import { uuidv4 } from 'Editor/scripts/utilities'

/*
Actions:
  mapInit
  objectHighlight
  objectUnhighlight
  objectClick
  tooltipShow
  tooltipHide
  changeArtboard
*/

let subscribers = {}

window.ImageMapPro.subscribe = cb => {
  // Create a unique ID
  let id = uuidv4()
  subscribers[id] = cb
  return id
}
window.ImageMapPro.unsubscribe = id => {
  delete subscribers[id]
}
window.ImageMapPro.trigger = action => {
  for (let id in subscribers) {
    subscribers[id](action)
  }
}

// Example action object
let exampleAction = {
  type: 'actionName',
  payload: {
    map: 'map name',
    object: 'object title'
  }
}

// Example usage
function runExample() {
  ImageMapPro.subscribe(action => {
    console.log(action)
  })
  ImageMapPro.trigger({
    type: 'someAction',
    payload: {
      map: 'the map',
      object: 'the object',
      layer: 'the layer'
    }
  })
}
// runExample()