Skip to content

Latest commit

 

History

History
29 lines (18 loc) · 642 Bytes

File metadata and controls

29 lines (18 loc) · 642 Bytes

Store.subscribe( listener, [filter] )

Adds a listener function. The listener will be returned when using applyPatch.

Arguments

listener Function

The callback to be invoked after patching.

filter Function Optional

An optional function that filters what mutations have to be applied.

Returns Function

A function that unsubscribes.

Examples

import { createStore } from 'dop'

const store = createStore({ users: 0 })
const unsubscribe = store.subscribe(patch => {})
store.listeners.size // 1
unsubscribe()
store.listeners.size // 0