Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@reatom/logger: generate logs on ctx.get #647

Open
Akiyamka opened this issue Oct 1, 2023 · 0 comments
Open

@reatom/logger: generate logs on ctx.get #647

Akiyamka opened this issue Oct 1, 2023 · 0 comments
Assignees
Labels
bug Something isn't working
Projects

Comments

@Akiyamka
Copy link
Collaborator

Akiyamka commented Oct 1, 2023

Code example:

import { createCtx, atom } from '@reatom/core'
import { connectLogger } from '@reatom/logger'

const ctx = createCtx()
connectLogger(ctx)

const counterAtom = atom(0, 'counterAtom')
const doubledAtom = atom((ctx) => ctx.spy(counterAtom) * 2, 'doubledAtom')
counterAtom(ctx, 24)

console.log(ctx.get(doubledAtom)) // Should generate log

This code generate in logs only:

42

But if I add subscription before reading

import { createCtx, atom } from '@reatom/core'
import { connectLogger } from '@reatom/logger'

const ctx = createCtx()
connectLogger(ctx, { skipUnnamed: false })

const counterAtom = atom(0, 'counterAtom')
const doubledAtom = atom((ctx) => ctx.spy(counterAtom) * 2, 'doubledAtom')
ctx.subscribe(doubledAtom, () => null) // Subscription added

counterAtom(ctx, 24)
console.log(ctx.get(doubledAtom))

Logs generated as expected
image

@Akiyamka Akiyamka added the bug Something isn't working label Oct 1, 2023
@Akiyamka Akiyamka changed the title @reatom/logger: don't generate any logs on .get @reatom/logger: generate logs on .get Oct 1, 2023
@Akiyamka Akiyamka changed the title @reatom/logger: generate logs on .get @reatom/logger: generate logs on ctx.get Oct 1, 2023
@artalar artalar added this to To do in v3 Oct 17, 2023
@artalar artalar self-assigned this Oct 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
v3
To do
Development

No branches or pull requests

2 participants