• Stars
    star
    229
  • Rank 169,360 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 8 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Log Mobx Actions, Reactions, Transactions and Computations

MobX Logger

Always know what is really going on in your MobX application by logging just the right information.

mobx-logger


β˜…β˜…β˜… Like this project? Leave a star, follow on Twitter or donate to support my work! Thanks. β˜…β˜…β˜…

Install

NPM: npm install mobx-logger

CDN: https://unpkg.com/mobx-logger/mobx-logger.umd.js

Usage

import {enableLogging} from 'mobx-logger';

// optional
const config = {...};

enableLogging(config);

For Mobx 3 support please use Mobx Logger 0.6.0.

Options

Unlike MobX DevTools you can simply configure which particular information should be logged to the console. Currently Actions, Reactions, Transactions and Computations are supported.

{
    predicate: () => true|false,
    action: true|false,
    reaction: true|false,
    transaction: true|false,
    compute: true|false
}

Logger Config

You can disable logging for actions and computed properties by providing a static mobxLoggerConfig. This is useful to keep the console log clean, e.g. when using a large amount of Mobx models which would result in alot of console logs.

Here's an example of how to disable logging for all actions and computed properties for a given class:

class MyModel {
    static mobxLoggerConfig: {
        enabled: false
    };
    
    // ...
}

Alternatively you can disable logging for particular class methods:

class MyStore {
    static mobxLoggerConfig: {
        methods: {
            myAction: false
        }
    };
    
    @action myAction() {
        // calls to this method won't be logged
    }
}

You can combine the above examples to whitelist certain actions for being logged:

class MyStore {
    static mobxLoggerConfig: {
        enabled: false,
        methods: {
            myAction: true
        }
    };
    
    @action myAction() {
        // only calls to this method are being logged
    }
    
    // other methods won't be logged ...
}

Please keep in mind that at this point mobxLoggerConfig is only available for actions (@action) and computed properties (@computed).

ReactNative

For ReactNative development use this predicate to only enable logging in dev mode with JS debugging enabled:

enableLogging({
    predicate: () => __DEV__ && Boolean(window.navigator.userAgent),
    ...
});

License

MIT

More Repositories

1

java8-tutorial

Modern Java - A Guide to Java 8
Java
16,488
star
2

streamjs

Lazy Object Streaming Pipeline for JavaScript
JavaScript
863
star
3

github-matrix-screensaver

The GitHub Matrix Screensaver for Mac OSX
JavaScript
554
star
4

spring-react-example

Isomorphic Spring Boot React.js Example
JavaScript
526
star
5

sequency

⚑️ Type-safe functional sequences for processing iterable data
TypeScript
338
star
6

github-matrix

The GitHub Matrix
Java
206
star
7

spring-kotlin-react-demo

Demo Webapp using SpringBoot, Kotlin and React.js
JavaScript
186
star
8

expekt

BDD assertion library for Kotlin
Kotlin
172
star
9

react-samples

Just a bunch of React.js examples
JavaScript
77
star
10

nake

A simplified Make for Java 8 Nashorn
JavaScript
72
star
11

jest-teamcity-reporter

Teamcity Reporter for Jest Unittest Results
JavaScript
50
star
12

java8-explorer

Java 8 API Explorer
Java
49
star
13

RNTimerExample

πŸ“± React Native + Mobx sample app
JavaScript
42
star
14

better-java

Resources for writing modern Java
36
star
15

javadoc-reloaded

Proposal for JEP 225: Javadoc Search
CSS
35
star
16

kotlin-examples

Kotlin code samples
Kotlin
15
star
17

algorithms

Various Algorithms written in ES6
JavaScript
11
star
18

challenge

Programming challenges
Kotlin
10
star
19

chaya

An HTML5 Web Chat
JavaScript
9
star
20

dotfiles

My personal dotfiles for Mac OSX terminal
Shell
7
star
21

chrome-bookmarks

Extension for Google Chrome to show your bookmarks in a compact popup
JavaScript
4
star
22

android-moneysheet

Money Sheet for Android
Java
3
star
23

compary

A library for composing complex compare-functions in JavaScript
TypeScript
2
star
24

sway

TypeScript
1
star
25

FoodTracker

Sample iOS App written in Swift
Swift
1
star
26

langs

Learning new programming languages
Swift
1
star