npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@28stoneconsulting/openfin-ngrx

v1.1.6

Published

## Motivation

Downloads

18

Readme

OpenfinNgrx

Motivation

Synchronizing multiple OpenFin windows to a single state or in some cases multiple states is a difficult task which results in complex management and repetitive code.

Implementing such a communication solution for multiple windows that transfer a decent amount of data between them takes a lot of effort, especially if you have multiple states that are shared.

The solution

OpenfinNgrx offers an easy to use solution. It seamlessly dispatches actions and selects data from states across multiple windows.

Usage

OpenfinNgrx delivers an Angular service with the following methods:

dispatchToParent - Dispatch NGRX action to the window parent.

dispatchToWindow - Dispatch NGRX action to a specific Openfin window that matches the given window name.

dispatchToRoute - Dispatch NGRX action to all windows on the specific route.

selectFromWindow - select data from the state of the window that matches the given window name.

selectFromParent - select data from parent window state.

Change detection

By default NgZone isn't aware of the OpenFin IAB. This may cause issues when messages from IAB are received and the change detection isn't triggered. OpenfinNgrx takes care of this problem by triggering the Angular change detection after every action that affects the window such as dispatching an action received from another window or receiving data from another window's state.

OpenfinNgrxService usage example

Dispatch increment action to the parent window's store.

export class ChildWindowComponent {
  constructor(private openfinNgrxService: OpenfinNgrxService) {}

  increaseCounterOnParentWindow(increaseBy) {
    this.openfinNgrxService.dispatchToParent(
      incrementAction({ paylaod: increaseBy })
    );
  }
}

OpenfinNgrx will dispatch the action to the parent window's state, assuring that the Angular change detection will be triggered on the parent window.

It is also possible to import OpenfinNgrxMetareducerModule to register NGRX metareducer that will call OpenfinNgrxService methods based on action routing metadata.

Metareducer usage example

Dispatch increment action to the particular window's store.

import { createAction, props, Store } from "@ngrx/store";
import { RoutingInfo } from "@28stoneconsulting/openfin-ngrx";

export const incrementBy = createAction(
  "[Counter] IncrementBy",
  props<{ payload: number; routing?: RoutingInfo }>()
);

export class ChildWindowComponent {
  constructor(private store: Store) {}

  increaseCounterOnParentWindow(increaseBy) {
    this.store.dispatch(
      incrementBy({
        paylaod: increaseBy,
        // type: 'parent' | 'window' | 'route'
        // remoteOnly flag blocks local dispatch of an action
        // if no routing info is provided then action is dispatched only locally as usual
        routing: {
          receivers: [{ type: "window", name: "window_name" }],
          remoteOnly: true,
        },
      })
    );
  }
}

Dispatch increment action to the parent window's sate with action creator with prconfigured routing info.

import { createAction, Store } from "@ngrx/store";
import { routingProps } from "@28stoneconsulting/openfin-ngrx";

export const incrementParentBy = createAction(
  "[Counter] IncrementBy",
  routingProps<number>({ type: "parent" }, true)
);

export class ChildWindowComponent {
  constructor(private store: Store) {}

  increaseCounterOnParentWindow(increaseBy) {
    this.store.dispatch(incrementParentBy(increaseBy));
  }
}

Demo

To clone and run the demo you'll need Git and Node.js (which comes with npm) installed on your computer. From your command line:

# Clone this repository
git clone https://github.com/28StoneConsulting/openfin-ngrx.git
# Go into the repository
cd openfin-ngrx
# Install dependencies
npm install
# Run the the demo
npm start