Skip to content

Commit 18949fd

Browse files
committed
Merge pull request reduxjs#1191 from jmrog/store-unsubscribe-documentation
Adds documentation about unsubscribing store listeners to Store.md
2 parents 891a97c + f6e2904 commit 18949fd

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

docs/basics/Store.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ The **Store** is the object that brings them together. The store has the followi
77
* Holds application state;
88
* Allows access to state via [`getState()`](../api/Store.md#getState);
99
* Allows state to be updated via [`dispatch(action)`](../api/Store.md#dispatch);
10-
* Registers listeners via [`subscribe(listener)`](../api/Store.md#subscribe).
10+
* Registers listeners via [`subscribe(listener)`](../api/Store.md#subscribe);
11+
* Handles unregistering of listeners via the function returned by [`subscribe(listener)`](../api/Store.md#subscribe).
1112

1213
It’s important to note that you’ll only have a single store in a Redux application. When you want to split your data handling logic, you’ll use [reducer composition](Reducers.md#splitting-reducers) instead of many stores.
1314

@@ -36,6 +37,7 @@ import { addTodo, completeTodo, setVisibilityFilter, VisibilityFilters } from '.
3637
console.log(store.getState())
3738

3839
// Every time the state changes, log it
40+
// (Note that `store.subscribe` returns a function for unregistering the listener)
3941
let unsubscribe = store.subscribe(() =>
4042
console.log(store.getState())
4143
)

0 commit comments

Comments
 (0)