Skip to content
プロジェクト

ivantsov/redux-subscriber

GitHubで見る

概要

Subscribe to changes in any part of redux state

Web・アプリ開発

この数値の測り方

計測したスター増加

24時間
0
7日間
0
15日間
0
1か月
履歴を収集中

期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。

redux-subscriber

Build Status codecov npm version

This package allows you to subscribe to changes in any part of Redux state.

Installation

npm install redux-subscriber --save

Usage

store.js

import {createStore} from 'redux';
import initSubscriber from 'redux-subscriber';

const store = createStore(...);

// "initSubscriber" returns "subscribe" function, so you can use it
const subscribe = initSubscriber(store);

somewhere-else.js

// or you can just import "subscribe" function from the package
import {subscribe} from 'redux-subscriber';

const unsubscribe = subscribe('user.messages.count', state => {
  // do something
});

// if you want to stop listening to changes
unsubscribe();

Examples

API

initSubscriber(store) (default export) - initialize redux-subscriber, so after that you can use subscribe method.

Options

  • store - instance of Redux store.

Returns subscribe function.

subscribe(key, callbackFunction) - subscribe callbackFunction to changes.

Options

  • key - string which specified the part of state (e.g. user.message.count) to listen to.
  • callbackFunction - function which will be called when the part of state has changed. New state is passed as a parameter.

Returns unsubscribe function which can be called to unsubscribe from changes.

関連プロジェクトを探す

読み込み中…