Ammonix / redux-state-observable

A tiny node module which returns the path to a redux state property as an rxjs/observable using object-path.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

redux-state-observable

Build Status Coverage Status Conventional Commits npm david Known Vulnerabilities

NPM

A tiny node module which returns the path to a redux state property as an rxjs/observable using object-path.

Installation and Usage

Install via npm and use with typescript

npm i redux-state-observable

To import and use the function:

import { getValue$ } from "redux-state-observables";
const objectPath: string[] = ["object", "property"];
const name$: Observable<TState> = getValue$<TState, TValue>(store, objectPath); // TState represents the state type of the redux store (the type of the root object) while TValue represents the type of the value you want to subscribe to
const nameSubscription: Subscription = name$.subscribe(value =>
  console.log(value)
);
nameSubscription.unsubscribe();

API

The following is the typescript function definiton:

getValue$<TState, TValue = TState>( // Note that TValue is a optional paramter
  store: Store<TState>,
  objectPath: ObjectPathGlobal.IPath = "" // Note that the objectPath is an optional parameter.
): Observable<TValue>

About

A tiny node module which returns the path to a redux state property as an rxjs/observable using object-path.

License:MIT License


Languages

Language:TypeScript 100.0%