项目作者: flintinatux

项目描述 :
Tiny vdom app framework. Pure Redux. No boilerplate.
高级语言: JavaScript
项目地址: git://github.com/flintinatux/puddles.git
创建时间: 2016-08-22T04:46:45Z
项目社区:https://github.com/flintinatux/puddles

开源协议:

下载



puddles


Pure Redux. No boilerplate.


npm version
npm downloads
gzip-size


Build Status
Coverage Status

Introduction

The main goal of puddles is to make the Redux pattern easy, without all of the boilerplate. If you like the Redux pattern, but wish you could code it in a more functional style, then puddles is for you.

With puddles you get all of these for free:

To whet your appetite, try the obligatory Hello World example:

  1. const { compose, constant, merge, path } = require('tinyfunk')
  2. const p = require('puddles')
  3. const actions = {
  4. reset: constant(p.action('RESET', null)),
  5. setName: p.action('SET_NAME')
  6. }
  7. const reducers = {
  8. name: p.handle('world', {
  9. RESET: constant('world'),
  10. SET_NAME: (state, name) => merge(state, { name })
  11. })
  12. }
  13. const targetVal = path(['target', 'value'])
  14. const view = (actions, state) => {
  15. const { reset, setName } = actions
  16. const { name } = state
  17. return p('div#root', [
  18. p('div.greeting', `Hello ${name}!`),
  19. p('input.name', {
  20. attrs: { placeholder: 'Enter name...' },
  21. on: { input: compose(setName, targetVal) },
  22. props: { value: name }
  23. }),
  24. p('button.reset', { on: { click: reset } }, 'Reset')
  25. ])
  26. }
  27. const root = document.getElementById('root')
  28. p.mount({ actions, reducers, root, view })

Notice anything missing? There is no dispatch function! The setName action creator attached to the input event is composed with the dispatch function internally.

Impressed? Read the full documentation to learn more.