How can I temporarily disable dependency registration? #3958
Answered
by
mweststrate
ofersadgat
asked this question in
General
Replies: 1 comment
-
That is what the untracked API is for 😀
…On Sat, Nov 9, 2024, 7:01 PM ofersadgat ***@***.***> wrote:
Hi, I'm trying to debug my application, and in doing so I want to print
the value of an object at a certain point in time. The problem is that I'm
trying to print the value of the property during a computation which is
changing the dependency list for that computation which screws up the
application. After looking through the source for reportObserved, it seems
like I can hack this by doing something like:
import { _getGlobalState } from "mobx";function runWithoutObserving(fn: () => any){
const globalState = _getGlobalState();
const derivation = globalState.trackingDerivation;
const inBatch = globalState.inBatch;
globalState.trackingDerivation = null;
globalState.inBatch = 0;
fn();
globalState.trackingDerivation = derivation;
globalState.inBatch = inBatch;}function printValueWithoutObserving(observableItem: any){
runWithoutObserving(() => {
console.log(JSON.stringify(observableItem));
});}
but I was wondering if there is a better way of doing this than the above.
Thanks!
—
Reply to this email directly, view it on GitHub
<#3958>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN4NBC6TGZONGAFWSSWABTZ7ZEWFAVCNFSM6AAAAABRPKZZBKVHI2DSMVQWIX3LMV43ERDJONRXK43TNFXW4OZXGQ2TCNZTGY>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ofersadgat
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I'm trying to debug my application, and in doing so I want to print the value of an object at a certain point in time. The problem is that I'm trying to print the value of the property during a computation which is changing the dependency list for that computation which screws up the application. After looking through the source for reportObserved, it seems like I can hack this by doing something like:
but I was wondering if there is a better way of doing this than the above. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions