Halogen integration for Hylograph force simulations.
Provides utilities for integrating Hylograph force simulations with Halogen applications, including event emitters that work with Halogen's subscription system.
spago install hylograph-simulation-halogenimport Hylograph.ForceEngine.Halogen (toHalogenEmitter)
import Hylograph.Simulation (runSimulation, SimulationEvent(..))
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 }The events are Hylograph.Simulation's: Tick { alpha, nodeCount },
Started, Stopped and Completed. Cancelling the Halogen subscription,
as Halogen does when the component is finalized, also unsubscribes from the
simulation.
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), which this module re-exports.
Their constructors share names with the ones above, so import one set or
the other, or qualify. subscribeToSimulation takes the simulation's
callbacks over: anything written to them before is replaced.
Changed in 0.6.1. Builds against hylograph-simulation 1.x or 2.x
(2.0 moved the transition consumers to hylograph-transitions, which this
package never used). toHalogenEmitter no longer leaves a listener on the
simulation's emitter after its Halogen subscription ends. Tests: spago test.
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).
Hylograph.ForceEngine.Halogen- Halogen emitter adapter
- hylograph-simulation-halogen - Halogen integration (this package)
- hylograph-simulation - Core simulation API
- hylograph-forces - the force kernel, in PureScript
MIT