Skip to content

Wikia/post-quecast

Repository files navigation

Post Quecast

npm version npm downloads Travis Renovate Travis

Travis Travis Travis Travis Travis

Post Quecast - Post Message based Queued Broadcast.

It is callback powered lib for creating semi-distributed communication system between iframes and window instances. The distinct feature of the lib is ability to remember (queue) messages so that it doesn't matter when a communicator is instantiated it will get full message history.

It is heavily inspired by Redux and NgRx and aims to create similar API.

Table of Contents

Installation

To install post-quecast:

npm install @wikia/post-quecast

Usage

The most basic usage is:

// top window that loads first
import { setupPostQuecast } from '@wikia/post-quecast';

setupPostQuecast();
// anywhere, including iframes
import { Communicator } from '@wikia/post-quecast';

const communicator = new Communicator();

communicator.addListener(console.log);
communicator.dispatch({ type: 'action name', ...payload });

More detailed explanation can be found in API section.

More advanced examples on how to integrate PostQuecast with things like RxJs and be found in Addons Section.

Restrictions

  • setupPostQuecast needs to be called before anything else.
  • setupPostQuecast needs to be called on top level window.