Skip to content
프로젝트

소개

Subscribe to changes in any part of redux state

웹 및 앱 개발

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

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.

관련 프로젝트 살펴보기

불러오는 중…