@swear-js/logger
TypeScript icon, indicating that this package has built-in type declarations

2.1.2 • Public • Published

🍭 Swear JS

@swear-js/logger


npm npm type definitions npm bundle size GitHub

Logger package for SwearJS state manager

Installation

$ 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:

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.

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');
    }
}));

Package Sidebar

Install

npm i @swear-js/logger

Weekly Downloads

2

Version

2.1.2

License

MIT

Unpacked Size

5.95 kB

Total Files

11

Last publish

Collaborators

  • askarovich