Mesh is a utility library for async iterable iterators.
This library was originally created to handle complex data flows, and unify how applications communicate internally and externally. It also serves as a single channel for all communication which makes it more easy to control & reason about how your application is passing around data asynchronously.
Mesh provides a set of higher order functions that you can use to build your data flows out. Here's an example of that:
import { when, wrapAsyncIterableIterator, fallback } from "mesh";
import {
DS_FIND,
DS_INSERT,
DS_REMOVE,
DS_UPDATE,
dataStore,
DSFindMessage,
whenCollection,
DSInsertMessage,
DSRemoveMessage,
DSUpdateMessage,
} from "mesh-ds";
const insertTodoItem = (message: DSInsertMessage) => (
wrapAsnycIterableIterator(fetch('/api/todos', {
method: 'POST',
body: message.data
}))
);
const insert = fallback(
whenCollection('todos', insertTodoItem),
// more collections below
// whenCollection('users', insertUser),
// whenCollection('items', insertItem),
);
const dsDispatch = dataStore({
[DS_INSERT] : insert,
// other operations - similar code to insert
//[DS_REMOVE] : remove,
//[DS_UPDATE] : update,
//[DS_FIND] : find
});
NPM: npm install mesh
Bower: bower install mesh
- Documentation
- Examples
- Modules
- Data Store Adapters
- in-memory data store bus
- mongodb bus
- lokijs bus - lokijs in-memory adapter
- local storate bus - local storage DS adapter
- array bus - persist DS operations to an array collection
- Realtime Protocol Adapters
- Other Adapters
- http bus - HTTP request bus
- Other Busses
- upsert ds action - adds upsert (insert/update) action for DS busses
- tailable bus - adds ability to listen for all executed operations
- remote protocol adapter bus - adapter bus for any realtime protocol
- Data Store Adapters
- Discuss
- Companies using Mesh
- Articles