The Current State of Affairs
So I’ve been wrapping a few components from MDC Web (Material Design).
When I create an html element
HH.div [ HP.id $ "prefix-string-" <> show generatedId ] [ ]
Say I want a reference to the HTMLElement I’ve just created, I can use the
web-html libraries to get a reference:
window >>= document >>= ( \doc -> querySelector (QuerySelector "#prefix-string-17625") (toParentNode doc) )
I can put the
element into my component’s state so I can instantiate the MDC Web component with a root element during initialization and call
mdcComponent.destroy() (Via FFI) when the halogen component is finalized to clean up the MDC Web component.
Right now, if I supply my component with an ID, this works pretty straight forwardly. If not, however, I need to generate an ID that is unique across the entire SPA.
It means that either every button in my app must becomes aware of some global state or every button must be given an unique ID by it’s parent component (by whatever means).
I’m pretty new to a lot of this, are there any mechanisms exposed by Halogen that would get me away from using low level libraries like
const elem = document.createElement('div');