All files singleton.ts

100% Statements 34/34
100% Branches 8/8
100% Functions 8/8
100% Lines 34/34

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 481x 1x 1x   1x     1x   1x 1x 1x   1x 1x 1x   1x   1x 1x 1x   1x 1x 1x   1x 1x 1x 1x   1x 7x 7x   1x 7x 7x   1x 4x 4x   1x 7x 7x  
import { Flowful, IFlowful } from './flowful';
import { DispatchMiddleware, DispatchMiddlewareCallback } from './dispatch-middleware';
import { ActionHandlerMiddleware, ActionHandlerMiddlewareCallback } from './action-handler-middleware';
import { Action } from './action';
import { createActionMap } from './action-map';
import { ActionHandler } from './action-handler';
 
export const dispatchMiddleware = new DispatchMiddleware();
 
export function addDispatchMiddleware(callback: DispatchMiddlewareCallback) {
  return dispatchMiddleware.add(callback);
}
 
export function removeDispatchMiddleware(callback: DispatchMiddlewareCallback) {
  return dispatchMiddleware.remove(callback);
}
 
export const handlerMiddleware = new ActionHandlerMiddleware();
 
export function addHandlerMiddleware(callback: ActionHandlerMiddlewareCallback) {
  return handlerMiddleware.add(callback);
}
 
export function removeHandlerMiddleware(callback: ActionHandlerMiddlewareCallback) {
  return handlerMiddleware.remove(callback);
}
 
export const flowful: IFlowful = new Flowful({
  dispatchMiddleware,
  handlerMiddleware,
});
 
export function hasHandler(handler: ActionHandler) {
  return flowful.hasHandler(handler);
}
 
export function addHandler(handler: ActionHandler) {
  return flowful.addHandler(handler);
}
 
export function removeHandler(handler: ActionHandler) {
  return flowful.removeHandler(handler);
}
 
export function dispatch(...actions: Action[]) {
  return flowful.dispatchActionMap(createActionMap(...actions));
}