Skip to content

State transition logger for Miso heavily inspired by Redux-Logger.

License

Notifications You must be signed in to change notification settings

Lermex/miso-action-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MisoActionLogger Hackage

State transition logger for Miso

MisoActionLogger helps you quickly develop and debug your Miso apps by wrapping your update function to log every evaluated action and show you the app state before and after.

Screenshot of the logger in operation

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:

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:

ghcjs.callCabal2nix "client" ./. {
  miso = miso-ghcjs;
  miso-action-logger = miso-action-logger;
}

Usage

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   

About

State transition logger for Miso heavily inspired by Redux-Logger.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published