Code Monkey home page Code Monkey logo

miso-action-logger's Introduction

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   

miso-action-logger's People

Contributors

lermex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

miso-action-logger's Issues

Support jsaddle

It would be great if this package could depend on jsaddle instead of ghcjs-base in order to support the hot-reload miso workflow.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.