| 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.Reload
Contents
Description
Support for live reloading of miso applications.
Live Reload
This module exposes two functions meant to be used during interactive
development with GHC WASM browser mode, live and reload.
Reload
Use reload if you'd like to redraw the page on each file change, resetting
the working application state.
main :: IO () main =reloaddefaultEventsapp
Live
Use live if you'd like to persist the working application state (all Component model)
between GHCi reloads. This only works if you do not alter the model schema (e.g. add, remove, change a field's type).
main :: IO () main =livedefaultEventsapp
See the miso-sampler for example usage.
Functions
reload :: Eq model => Events -> App model action -> IO () Source #
Clears the <body> and <head> on each reload.
Meant to be used with WASM browser mode.
main :: IO () main =reloaddefaultEventsapp
N.B. This also resets the internal component state. This means all currently
mounted components become unmounted and ComponentId are reset to their
original form factory.
If you'd like to preserve application state between calls to GHCi `:r`, see live.
Since: 1.9.0.0
live :: Eq model => Events -> App model action -> IO () Source #
Live reloading. Persists all Component model between successive GHCi reloads.
This means application state should persist between GHCi reloads
Schema changes to model are currently unsupported. If you're
changing fields in model (adding, removing, changing a field's type), this
will more than likely segfault. If you change the view or update functions
it will be fine.
Use reload if you're changing the model frequently and live
if you're adjusting the view / update function logic.
main :: IO () main =livedefaultEventsapp
Since: 1.9.0.0