Logger for swear-js
npm install @swear-js/loggerLogger package for SwearJS state manager
$ npm install @swear-js/logger
`or in case you are using Yarn:
`
$ yarn add @swear-js/logger
`Usage
___
You can pass your custom logger to the store, or use @swear-js/logger.
Swear-js logger usage:`typescript
import { createStore } from "@swear-js/core";
import { swearLogger } from "@swear-js/logger";const store = createStore({ onPatch: swearLogger });
`Tagging
Architecture of SwearJs is built that way, patches know anything about action from where mutation was triggered. Didn't expect that, soon will be trying to fix it.
Instead you can use tagging while mutating.
Mutate function gets string tag as a second argument.
`javascript
export const countSwear = createSwear('counter', defaultState, (mutate) => ({
decrease: () => {
// You can also access previous value like this
mutate((prev) => prev - 1, 'SOME TAG THAT WILL BE SHOWN IN LOGS');
}
}));
``