0.32.0 • Published 8 years ago

rille v0.32.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

Rille Build Status Coverage Status npm version npm downloads PRs Welcome

Think of Rille as a key-value store and router for your application state. You could also think of it as a message broker / data pipeline for your application state.

Consuming portions of your application can subscribe to well known routes and simply wait for data to be pushed to them while producing portions of your application can push data without worrying about who is consuming data on the other end.

Quick Links

General

Modules

Examples

TBD

Back To Top

Installation

npm install rille --save

Back To Top

Contributing

  • To Build: npm run build
  • To Test: npm test

Back To Top

Entry

Entry provides some convenience functions for working with entries. An entry is an array where the head is the key and the tail contains values (e.g.: '/some/key', value1, value2, ...).

import {Entry} from 'rille';

// Returns the array of values for an entry
var values = Entry.values(entry);

// Returns a specific value for the given entry
var value = Entry.value(entry, 0);

// Returns the key of an entry
var key = Entry.key(entry);

Back To Top

Key

Key provides convenience functions for parsing and stringify'ing keys.

import {Key} from 'rille';

// Converts string format into array format
var keys = Key.parse('/i/am/a/key');

// Return only specific key fragments (useful for parameter extraction)
var [id] = Key.parse('/users/123243/', [1]);  // Will set id = 123243

// Converts array format into string format
var key = Key.stringify(['i','am','a','key']);

Back To Top

Route

Route is the core of Rille and provides support for routing entries (key + values) to appropriate subscribers.

import {Route} from 'rille';

// Create a route
const route = Route();

// Subscribe to receive updates to a route
route.subscribe((key, ...values) => {
    console.log('My key is ' + key + ' and my values are ' + JSON.stringify(values));
});

// Subscribe to receive updates on a child route
route('/child/1').subscribe((key, ...values) => {
    console.log('My key is ' + key + ' and my values are ' + JSON.stringify(values));
});

// Subscribe to receive updates for all child of a route (a wildcard route)
route('/child/*').subscribe((key, ...values) => {
    console.log('Wildcard Route: My key is ' + key + ' and my values are ' + JSON.stringify(values));
});
                 
// Push a value(s) to a route
route.push('Hi!');

// Push value(s) of any type to a route
route.push('Hi!', {user: 'Frank'}); 

// Push value(s) to a child route
route('/child/1').push('Hi child!');

Back To Top

Store

Store is a route that retains it's most recent entry.

import {Store} from 'rille';

// Create a store just like a route
const store = Store();

var child = store('/some/child');

// Subscribe to a store just like a route
child.subscribe((...entry) => {
    console.log('received ' + JSON.stringify(entry));
});

// Push to a store just like a route
child.push('Hello child!');

// Get the most recent entry
var entry = child.entry();
console.log('most recent entry ' + JSON.stringify(entry));

// Get the array of values for the most recent entry
var values = child.values();
console.log('most recent values ' + JSON.stringify(values));

// Get a particular value from the most recent entry
console.log('message is "' + child.value(0) + '".');

Back To Top

Change Log

0.32.0

  1. Entry.value(entry) and Store.value() default to returning 1st value.

0.31.0

  1. Add Entry.value(entry, loc) and store.value(loc).

0.29.0

  1. Fixed a bug in push.
  2. Removed functionTree and functionTrees support.

0.28.0

  1. Reworked middleware to support async behaviour and provide access to the route object.

0.26.0

  1. Added early middleware implementation.

0.25.0

  1. Key.parse now supports parameter extraction.

0.23.0

  1. Add functionTree to Route objects.
  2. Add functionTrees to Route objects.
  3. Entry.values and Store.values should always return an array.

0.21.0

  1. push now returns the route for chaining.

0.20.0

  1. Entry.data() is now Entry.values() and store.data is now store.values.

0.16.0

  1. Entry.data() always returns an array.

0.13.0

  1. Added Entry.

Back To Top

0.32.0

8 years ago

0.31.0

8 years ago

0.30.0

8 years ago

0.29.0

8 years ago

0.28.0

8 years ago

0.27.1

8 years ago

0.27.0

8 years ago

0.26.0

8 years ago

0.25.0

8 years ago

0.23.1

8 years ago

0.23.0

8 years ago

0.22.0

8 years ago

0.21.0

8 years ago

0.20.0

8 years ago

0.19.0

8 years ago

0.18.0

8 years ago

0.17.0

8 years ago

0.16.0

8 years ago

0.15.0

8 years ago

0.14.0

8 years ago

0.13.0

8 years ago

0.12.0

8 years ago

0.11.0

8 years ago

0.10.0

8 years ago

0.9.0

8 years ago

0.8.1

8 years ago

0.8.0

8 years ago

0.7.0

8 years ago

0.6.0

8 years ago

0.5.3

8 years ago

0.5.2

8 years ago

0.5.1

8 years ago

0.5.0

8 years ago

0.0.12

8 years ago

0.0.11

8 years ago

0.0.10

8 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago