GithubHelp home page GithubHelp logo

shripadk / flocks.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stonecypher/flocks.js

0.0 2.0 0.0 88 KB

A radically simpler alternative to Flux - opinionated React state and rendering management

License: MIT License

flocks.js's Introduction

flocks

A radically simpler alternative to Flux - opinionated React state and rendering management

Language   Platform   License   Status

NPM Downloads

WARNING

This is pre-release software. This is the right way forwards, but it's only just on the verge of ready, and bugs should be expected. The base API is now stable, but will soon be extended. Proper tutorial on the way very soon :)

Please consider this a beta product.

The hell is this?

So flux is pretty cool. But, I wanted something simpler, because I wanted to move faster. So, I created flocks - a flux alternative.

What's the big deal

There's basically no boilerplate, and updating is easy.

You know that whole thing in Flux where you have to create stores and dispatchers and constant files and decide how many of each there'll be and set up bindings and so on?

var Target = document.getElementById('whatever'),
    Update = Flocks.create({ target: Target, control: YourControl });

Update({ logged_in: true, user_name: "Bob Dobbs", icon: "http://..." });

Done.

If you want that from inside the control, or even inside the heirarchy, that's fine; props, state, and contexts will cascade down safely and normally.

Now, you just write your app as a single control, and keep state 100% outside of the control heirarchy. :)

More clearly?

What Flocks actually does is to provide you with an update function.

To get started, tell Flocks where the mount point is and what control to use. Then, Flocks will create that control in place, and provide you an update function. What you do with that function is up to you, though it's recommended that you pass it downwards, for use by your control and its children (and a mixin is provided to automate that, if you like.)

Then, Flocks will update the top-level control when the state it manages changes, by applying each key to a prop in the top-level.

The idea is that you're supposed to let Flocks manage the part of your application's state that gets visibly rendered. (You can let it manage the whole state, if you want to; I do. But you don't have to.)

Once that's done, the whole shebang is just taken off your shoulders. No update calls. No dispatching. No events. No broadcasting. No registration or deregistration.

Just simple prop updates. It's quite liberating.

Example plox

One example is flocks-mini-todo (github). More are coming soon.

Endnotes

Are you using my lib? Please let me know. I'm curious!

If you want to reach me, try stonecypher at gmail dot com, please. Thanks :)

Polemic :neckbeard:

flocks is MIT licensed, because viral licenses and newspeak language modification are evil. Free is only free when it's free for everyone.

flocks.js's People

Contributors

stonecypher avatar

Watchers

Shripad Krishna avatar James Cloos 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.