Skip to main content
All Examples

Charting

Live dashboard for public Foldkit telemetry from GitHub and npm. Demonstrates HTTP Commands, async state, an ECharts Mount adapter, and a Subscription that turns chart clicks back into Messages.

Charts
HTTP
Mount
Subscriptions
Third-Party Library
/
import type { EChartsType } from 'echarts/core'
import { Option } from 'effect'

const chartsByHostId = new Map<string, EChartsType>()

export const setChart = (hostId: string, chart: EChartsType): void => {
  chartsByHostId.set(hostId, chart)
}

export const getChart = (hostId: string): Option.Option<EChartsType> =>
  Option.fromNullishOr(chartsByHostId.get(hostId))

export const removeChart = (hostId: string): void => {
  const maybeChart = getChart(hostId)

  if (Option.isSome(maybeChart)) {
    maybeChart.value.dispose()
    chartsByHostId.delete(hostId)
  }
}