Giter Club home page Giter Club logo

actions-recorder's Introduction

React Actions Recorder, inspired by Redux

Demo http://ui.talk.ai/actions-recorder/

Tricks:

  • Click with "Shift" key pressing to step backward.
  • set inProduction true if you want to limit size of records to 400

Chinese Guide

Usage

npm i --save actions-recorder
# initial structure of store
initialStore = Immutable.fromJS []

# update a tree of store with Immutable APIs with pure function
updater = (store, actionType, actionData) ->
  store
recorder = require 'actions-recorder'

recorder.setup
  initial: initialStore
  updater: updater
  inProduction: false

render = (core) ->
  App = Page store: core.get('store')
  ReactDOM.render App, document.querySelector('.app')

recorder.request render
recorder.subscribe render
# if you have several args, use an Array or an Object
# argument will be turned into Immutable data
recorder.dispatch 'category/name', 'some arguments'

API Docs

recorder has methods:

  • recorder.setup(options)
  • recorder.hotSetup(options)
  • recorder.getStore()
  • recorder.getCore()
  • recorder.request (core) ->
  • recorder.subscribe (core) ->
  • recorder.unsubscribe(listener)
  • recorder.dispatch(actionType, actionData)

You will need recorder.getStore() or core.get('store') to find store.

display DevTools

Get Devtools:

# for component
Devtools = require 'actions-recorder/lib/devtools'

Devtools is a component to show actions:

React.createElement Devtools,
  core: core # internal data from recorder
  width: window.innerWidth
  height: window.innerHeight # flexbox not powerful enough, use JavaScript
  path: @state.path # path of JSON tree reader, use `Immutable.List()` as default
  onPathChange: (newPath) -> @setState path: newPath

Read code in src/ to get more details.

Basic Hot Module Replacement support

.hotSetup() is used in hot replacing updater and initial:

if module.hot
  module.hot.accept ['./updater', './schema'], ->
    schema = require './schema'
    updater = require './updater'
    recorder.hotSetup
      initial: schema.store
      updater: updater

Also read src/ for details. By now there's only basic support for HMR.

Background Image

http://www.fabuloussavers.com/new_wallpaper/DJ_Vinyl_Disc_freecomputerdesktopwallpaper_1920.jpg

Development

gulp html # generates index.html
webpack-dev-server --hot --host=0.0.0.0

License

MIT

actions-recorder's People

Contributors

tiye avatar

Stargazers

 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.