watergate

minimalistic interprocess communcation framework for javascript


License
MIT
Install
npm install watergate@0.0.3

Documentation

minimalistic interprocess communication framework for javascript

installation

npm install --save watergate

usage

creating the watergate

All communication channels are added through plugins, called gates. We will use watergate-graphql gate as an example.

import {createWatergate} from 'watergate';
import {createGraphqlGate} from 'watergate-graphql';

const watergate = createWatergate({
  graphql: createGraphqlGate('path_to_graphql_server')
});

creating an action

An action contains the gate to which the action should flow and the message it should send.

const action = {
  gate: 'graphql',
  payload: ...
}

dispatching an action

watergate.dispatch(action);

batching

A batch groups the actions per gate. It is the responsibility of the gate to multiplex the requests.

Only when all requests are resolved, the response is returned.

import {createBatch} from 'watergate'

const batch = createBatch({
  graphqlRequest1: action,
  graphqlRequest2: action,
  otherRequest: action
});

watergate.dispatch(batch);