mobx-log icon indicating copy to clipboard operation
mobx-log copied to clipboard

[Discussion] Should be there two different functions: makeLoggable and makeAutoLoggable?

Open inoyakaigor opened this issue 2 years ago • 2 comments

Currently I added mobx-log and got wall of text: image I don't need almost all of this logs exclude few specific so I think it will be better split function makeLoggable to two almost the same: makeAutoLoggable and makeLoggable. Difference between these is almost the same as makeAutoObservable and makeObservable:

constructor() {
  makeAutoLoggable(this)
}
constructor() {
  makeLoggable(this, [
    'methodName1', 
    'methodName2', 
    'variable1', 
  ])
}

i.e. makeLoggable requires explicit definition of methods/variables that should be logged.

I think it can be handful.

inoyakaigor avatar Mar 30 '23 15:03 inoyakaigor

It's a good idea and there are such feature requests already: https://github.com/kubk/mobx-log/issues/24

Introducing makeAutoLoggable is going to be a BC break, so we can stick with the following API:

makeLoggable(this) - logs everything related to the store makeLoggable(this, { filters: { events: { computed: true } } }) - logs only computed related to store. It's already implemented: https://github.com/kubk/mobx-log#log-observables--computeds--actions-of-a-specific-store makeLoggable(this, { filters: { events: { computed: ['isEven'] } } }) - could log only changes in isEven computed.

Seems like a nice addition. No ETA from my side yet, but I'll try to take into account that issue since it's getting quite popular.

kubk avatar Mar 30 '23 17:03 kubk

This will be very valuable. Thanks for having this under your radar!

TechAkayy avatar Apr 12 '23 01:04 TechAkayy