Skip to content

Why is it OK to always hold strong references to consumers? #79

@backbone87

Description

@backbone87

Hi,

When i was comparing the graph algorithm with the Signals proposal and other Signal implementations like jotai I noticed that alien-signals always hold a strong reference to downstream signals, while others only hold strong downstream references when the downstream is being watched (directly or indirectly). This allows unused computeds to be GCed, e.g.:

const s = signal(0)
let c = computed(() => s())
c()
c = undefined
// while the function `c` is GCed, its `this` context ("the graph node") and its link remain entangled with `s` forever.

Is this an intentional design decision? If yes, why is it ok?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions