Package

purescript-hylograph-simulation-halogen

Repository
afcondon/purescript-hylograph-simulation-halogen
License
MIT
Uploaded by
pacchettibotti
Published on
2026-11-19T09:26:05Z

Halogen integration for Hylograph force simulations.

Overview

Provides utilities for integrating Hylograph force simulations with Halogen applications, including event emitters that work with Halogen's subscription system.

Installation

spago install hylograph-simulation-halogen

Usage

import Hylograph.ForceEngine.Halogen (toHalogenEmitter)

handleAction Initialize = do
  { handle, events } <- liftEffect $ runSimulation config
  halogenEmitter <- liftEffect $ toHalogenEmitter events
  void $ H.subscribe $ halogenEmitter <#> SimEvent

handleAction (SimEvent (Tick { alpha })) =
  H.modify_ _ { alpha = alpha }

For a simulation made directly with Hylograph.ForceEngine.Simulation.createWithCallbacks, subscribeToSimulation gives a Halogen emitter of the engine's own events (Tick, Started, Stopped, AlphaDecayed).

Changed in 0.6.0. This package no longer depends on hylograph-d3-kernel. subscribeToSimulation takes the simulation of hylograph-simulation 1.x, not the D3 kernel's; D3SimulationEvent and D3SimulationCallbacks are now SimulationEvent and SimulationCallbacks, re-exported from Hylograph.ForceEngine.Events; and subscribeToGroup is gone, with the kernel that had groups (step several Hylograph.Simulation.Stepped handles from one animation loop instead).

Modules

  • Hylograph.ForceEngine.Halogen - Halogen emitter adapter

Part of Hylograph

  • hylograph-simulation-halogen - Halogen integration (this package)
  • hylograph-simulation - Core simulation API
  • hylograph-forces - the force kernel, in PureScript

License

MIT

Modules
Hylograph.ForceEngine.Halogen
Dependencies