Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docs/guides/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,10 @@ const loggerImpl: LoggerImpl = (f, name) => (set, get, store) => {
set(...a)
console.log(...(name ? [`${name}:`] : []), get())
}
store.setState = loggedSet
store.setState = (...a) => {
store.setState(...a)
console.log(...(name ? [`${name}:`] : []), store.getState())
}

return f(loggedSet, get, store)
}
Expand Down
5 changes: 5 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,11 @@ You can functionally compose your store any way you like.
```jsx
// Log every time state is changed
const log = (config) => (set, get, api) =>
api.setState = (...args) => {
console.log(' applying', args)
api.setState(...args)
console.log(' new state', get())
}
config(
(...args) => {
console.log(' applying', args)
Expand Down