| Copyright | (C) 2016-2026 David M. Johnson |
|---|---|
| License | BSD3-style (see the file LICENSE) |
| Maintainer | David M. Johnson <code@dmj.io> |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Miso.Runtime.Internal
Description
Overview
Miso.Runtime.Internal is a testing-only facade that re-exports the miso runtime's global mutable state from Miso.Runtime.
Do not import this module in application code. Mutating any of
the exported IORef values will corrupt the component
lifecycle and produce undefined behaviour. The module exists solely to
give the miso-tests integration-test package direct access to
component state for assertions.
Exported names
components— globalIORefmappingComponentIdtoComponentStatefor every mounted component.componentIds— monotonically increasingIORefused to assign fresh component identifiers.rootComponentId— the well-known identifier of the top-level app component.ComponentState— record holding the live model, scheduler mailbox, and other per-component runtime fields.schedulerThread—IORefholding theThreadIdof the event-loop scheduler thread.
See also
- Miso.Runtime — the authoritative definitions of everything exported here
- Miso.Reload — uses these internals to kill and restart the scheduler on
:r
Synopsis
- components :: IORef (IntMap (ComponentState parent props model action))
- componentIds :: IORef Int
- rootComponentId :: ComponentId
- data ComponentState parent props model action = ComponentState {
- _componentId :: ComponentId
- _componentKey :: Maybe Key
- _componentParentId :: ComponentId
- _componentProps :: props
- _prevComponentProps :: props
- _componentSubThreads :: IORef (Map MisoString ThreadId)
- _componentDOMRef :: DOMRef
- _componentVTree :: IORef VTree
- _componentSink :: action -> IO ()
- _componentModel :: model
- _componentIsDirty :: Bool
- _componentScripts :: [DOMRef]
- _componentEvents :: Events
- _componentBindings :: [Binding parent model]
- _componentMailbox :: Value -> Maybe action
- _componentDraw :: model -> IO ()
- _componentPropsPhase :: props -> props -> IO ()
- _componentModelDirty :: model -> model -> Bool
- _componentApplyActions :: Seq action -> model -> IntMap (ComponentState parent props model action) -> props -> (IntMap (ComponentState parent props model action), model, [Schedule action], ComponentIds)
- _componentTopics :: Map MisoString (Value -> IO ())
- _componentChildren :: ComponentIds
- schedulerThread :: IORef ThreadId
Documentation
components :: IORef (IntMap (ComponentState parent props model action)) Source #
componentIds :: IORef Int Source #
The global store of ComponentId, for internal-use only.
Used internally freshComponentId to allocate new ComponentId on
mount.
rootComponentId :: ComponentId Source #
This is used to demarcate the ROOT of a page. This ID will *never*
exist in the components map.
data ComponentState parent props model action Source #
Constructors
| ComponentState | |
Fields
| |
schedulerThread :: IORef ThreadId Source #
Global variable to hold the scheduler thread
N.B. undefined is safe here, it will always get populated.
Also, we use this in cleanup when interactive mode (GHCi) is detected
in that circumstance schedulerThread will always be populated. It's an
invariant.