Coder Social home page Coder Social logo

justinwoo / purescript-redux-devtools Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 2.0 8 KB

Some bindings to work with Redux DevTools.

License: MIT License

Makefile 0.65% HTML 1.30% JavaScript 4.73% PureScript 52.53% Nix 10.99% Dhall 29.80%
purescript redux-devtools

purescript-redux-devtools's Introduction

PureScript-Redux-DevTools

Some bindings to work with Redux DevTools.

This doesn't do any magic and you will have to handle your own encodings to Foreign and whatever.

Example usage

main :: Effect Unit
main = do
  mExt <- DT.getExtension
  case mExt of
    Just ext -> do
      log "Found extension"

      -- make instance
      inst <- DT.connect ext (DT.mkConnectOptions {})

      -- feed initial state to DevTools
      DT.init inst (JSON.write initialState)

      -- ref where i'll keep my state in this example
      ref <- Ref.new initialState

      let handle' = handle inst ref
      handle' (add_ 1)
      handle' (sub_ 1)
      handle' (add_ 1)

      -- listen and just print out what we get from DevTools
      DT.subscribe inst (log <<< JSON.writeJSON)
    Nothing -> do
      error "No extension found"
  where
    -- handler that will modify my state ref
    handle inst ref action = do
      s <- Ref.modify (update action) ref
      log $ "New action: " <> JSON.writeJSON action
      log $ "New state: " <> JSON.writeJSON s

      DT.send inst { state: JSON.write s, action: JSON.write action }

purescript-redux-devtools's People

Contributors

jmatsushita avatar justinwoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.