https://github.com/lermex/miso-action-logger
State transition logger for Miso heavily inspired by Redux-Logger.
https://github.com/lermex/miso-action-logger
ghcjs haskell miso
Last synced: 5 months ago
JSON representation
State transition logger for Miso heavily inspired by Redux-Logger.
- Host: GitHub
- URL: https://github.com/lermex/miso-action-logger
- Owner: Lermex
- License: bsd-3-clause
- Created: 2019-06-24T14:48:42.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-06-27T23:12:54.000Z (over 6 years ago)
- Last Synced: 2025-07-30T03:00:50.202Z (6 months ago)
- Topics: ghcjs, haskell, miso
- Language: Haskell
- Size: 8.79 KB
- Stars: 5
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
## MisoActionLogger [](http://hackage.haskell.org/package/miso-action-logger)
### State transition logger for Miso
**MisoActionLogger** helps you quickly develop and debug your [Miso](https://github.com/dmjio/miso)
apps by wrapping your `update` function to log every evaluated action and show you the app state
before and after.

We marshal your state tree to JS Objects to benefit from the rich object introspection features
of modern browser consoles. This imposes a `ToJSON` constraint on your models.
### Installation
**Option 1:** use `nix-prefetch-git` to generate arguments for `fetchFromGitHub`.
You'll end up with somthing like this:
```nix
miso-action-logger = ghcjs.callCabal2nix "miso-action-logger" (pkgs.fetchFromGitHub {
owner = "Lermex";
repo = "miso-action-logger";
sha256 = "1q6bpckz355paxcs10223fnl1d3lnxz2vcgj8l7nqvclicp04hsb";
rev = "917af7edc33e86b1510ebf2bc8e1b1bb9f03c164";
}) { miso = miso-ghcjs; }
```
**Option 2:** if your nixpkgs is recent enough, you can use `pkgs.callHackageDirect` to fetch
directly from Hackage.
In both cases you will then need to add the package to your build arguments like this:
```nix
ghcjs.callCabal2nix "client" ./. {
miso = miso-ghcjs;
miso-action-logger = miso-action-logger;
}
```
### Usage
```haskell
module Main where
import MisoActionLogger
-- ...
main :: IO ()
main = do
let model = Model -- ...
startApp App {model = model, ..}
where
initialAction = NoOp
update = defaultActionLogger updateModel -- <-- wrap your update function
view = Routing.view
events = defaultEvents
subs = [ uriSub HandleURI ]
mountPoint = Nothing
```