mobx-log
mobx-log copied to clipboard
[Discussion] Should be there two different functions: makeLoggable and makeAutoLoggable?
Currently I added mobx-log and got wall of text:
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.
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.
This will be very valuable. Thanks for having this under your radar!