npm

Share private packages across your team with npm Orgs, now with simplified billing via the aws marketplace!Learn more »

requerio

0.5.0-rc.1 • Public • Published

Redux + jQuery + Cheerio = predictable client-side state + server-side testability

Known Vulnerabilities Mac/Linux Build Status Windows Build Status Coverage Status License

BREAKING CHANGE!

As of v0.5.0, Requerio is far more strict about accepting arrays as the 2nd parameter for .dispatchAction(). Only a few action methods allow such arrays. They are restricted to after, append, before, prepend, and toggleClass.

Install:

npm install cheerio redux requerio

Declare $:

<script src="jquery.min.js"></script>
- or -
const cheerio = require('cheerio');
const html = fs.readFileSync('./index.html', 'utf8');
const $ = global.$ = cheerio.load(html);

Declare Redux:

<script src="redux.min.js"></script>
- or -
const Redux = global.Redux = require('redux');

Declare Requerio:

<script src="requerio.min.js"></script>
- or -
const Requerio = require('requerio');

Declare $organisms:

At declaration, organisms are just empty namespaces.

const $organisms = {
  '#yoda': null,
  '.midi-chlorian': null
};

Instantiate requerio:

const requerio = new Requerio($, Redux, $organisms);

Initialize requerio:

requerio.init();

Use:

// During initialization, the null `$organisms['#yoda']` underwent
// inception into Requerio organism `requerio.$orgs['#yoda']`. This
// organism has properties, methods, and state. It is home to the
// `.midi-chlorian` organisms. (A well-working application would want
// them to be symbionts and not parasites!) To demonstrate that `#yoda`
// is alive and stateful, let's dispatch a `css` action to give it a
// `color:green` style property.
requerio.$orgs['#yoda'].dispatchAction('css', {color: 'green'});
 
// This action will turn the organism's text green in the browser.
// We can observe its state after dispatching the action.
const mainState = requerio.$orgs['#main'].getState();
 
// In Node, we can test to ensure the action updated the state correctly.
assert.equal(mainState.style.color, 'green');

Why Requerio?

API docs

Methods supported:

See also the code examples.

install

npm i requerio

Downloadsweekly downloads

32

version

0.5.0-rc.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability