Giter VIP home page Giter VIP logo

nofux's Introduction

nofux

Join the chat at https://gitter.im/jayphelps/nofux build status npm version

Unpredictable state container for JavaScript apps. Rethinking best practices, when you're all out of fucks to give.

Install

npm install --save nofux

We publish CommonJS, ES2015, ESM, and UMD builds. We also include a TypeScript definition file.

UMD

We publish a UMD build inside our npm package. You can use it via the unpkg CDN:

https://unpkg.com/nofux@latest/dist/umd/nofux.min.js

Usage

Try reading the source code!

The central idea of nofux is that all of your application's state is contained in a single, global atom. This state tree is held on the nofux namespace, which is actually an alias to the global object in your JavaScript environment, e.g. window.

To update the state, simply assign a property on nofux! That's it! ...Unless you want your app to update too, in which you need to call this.forceUpdate() on your component.

JSBin Demo

import nofux from 'nofux';
// or
const nofux = window;

class Search extends React.Component {
  render() {
    return (
      <div>
        <input
          placeholder="Search..."
          value={nofux.search || ''}
          onChange={event => {
            nofux.search = event.target.value;
            this.forceUpdate();
          }}
        />
        <p>You have typed: {nofux.search || '(nothing yet)'}</p>
      </div>
    );
  }
}

No boilerplate, no fancy bindings or actions to dispatch. Truly global state!

Discuss

Join the chat at https://gitter.im/jayphelps/nofux

Everyone is welcome on our Gitter channel!

Credit

I was inspired by this video: https://www.youtube.com/watch?v=6wS5xOZ7Rq8

Note

This is a joke...or is it?

:shipit:

nofux's People

Contributors

jayphelps avatar

Watchers

James Cloos 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.