npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fun-react

v0.3.9

Published

Elm like js framework built on top of cycle-react

Downloads

33

Readme

Fun React

Join the chat at https://gitter.im/rayshih/fun-react

Fun React is a React framework.

Why?

Because I love functional programming and ELM, but I can only use JS in work.

Introduction

If you know ELM:

Great! Fun React is perfect for you. Because it basically mimic almost everything of ELM 0.17. I bet you can know how to use Fun React right after check the following example.

If you are using Redux:

The overall concept is the same: the state reducer. The main differences are:

  1. We call reducers as update functions
  2. We use simple type system to replace redux action
  3. We use program instead of <Provider />
  4. There is no connect.
    • For data, we encourage to pass data all the way down.
    • For event, we use very simple event system, there is only two function need to know:
      • event: event declaration
      • link: event binding between parent and children

If you are using Cycle React:

TODO

Installation

npm install --save fun-react cycle-react react rx

Example

To run example

cd examples/__the_example__
npm install
npm start

then open http://localhost:8080 in browser.

Basic counter

import React from 'react'
import ReactDOM from 'react-dom'
import {
  createProgram,
  fromSimpleInit,
  fromSimpleUpdate,
  createTypes,
  caseOf,
  createView
} from 'fun-react'

// 1. define message types by function createTypes
const Msg = createTypes('INC', 'DEC')

// 2. define init data
const init = 0

// 3. define update function
const update = caseOf({
  INC: (_, count) => count + 1,
  DEC: (_, count) => count - 1
})

// 4. define view by function createView
const Counter = createView('Counter', ({model}, {event}) => (
  <div>
    <h1>Count: {model}</h1>
    <button onClick={event(Msg.INC)}>INC</button>
    <button onClick={event(Msg.DEC)}>DEC</button>
  </div>
))

// 5. compose program by the defined `init`, `update`, `view`
const Program = createProgram({
  init: fromSimpleInit(init),
  update: fromSimpleUpdate(update),
  view: Counter,
  inputs: () => []
})

// 6. mount the Program to actual DOM
const rootEl = document.getElementById('app')
ReactDOM.render(<Program />, rootEl)

Nested counter

TODO

Use with vanilla React

TODO

Use with flowtype

TODO

Learn more

TODO

Philosophy

The name imply the philosophy. So why name it Fun React:

  1. We treat react element as a functor of event and the virtual dom is the context of the functor, so Fun React means: Functor React.
  2. It is fun.

TODO explain what is Functor, and why can react element be a functor

TODO

  • restructure examples
    • nested counter
    • todo list
    • cycle interoperable
    • react interoperable
  • write doc
    • README
    • API document
    • the config options
  • add jsbin env
  • add test
  • Try to upgrade to rx 5 or annotate rx 4

Contributers