Skip to content

Could store.observer be automatically cancelled on component destruction? #1181

Closed
@aphitiel

Description

@aphitiel

When destroying a component, observers observing component state get cancelled automatically while observers on store stay alive.

oncreate() {
  this.observe(...  // Gets cancelled
  this.store.observe(... // Stays alive

This came as a surprise to me, with a bit of foot-gun potential. Would it make sense to autocancel store-observers, too?

Here is a slightly contrived REPL. Nested.html has observers spammig the console. The store.observer keeps logging after pressing the button.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions