Skip to content

Self referencing derived store #4880

@antony

Description

@antony

Describe the bug
This is half bug, half proposal.

The current implementation of derived stores doesn't provide a way to use the store's existing value in the new value (a-la .update).

You can see in the REPL my workaround for this is to use get(storeName) which... sort of works.

The issue is that you get a console error which pertains to whatever the error you previously encountered was, which is written every time the store updates.

Logs

 Error: Uncaught (in promise): thir is not defined

To Reproduce
https://svelte.dev/repl/df25b5983b8d464fb1e47af7a1d12d61?version=3.22.3

Expected behavior
The current behaviour is correct, aside from the error.

Information about your Environment:

  • Svelte version 3.22.3

Severity
I do need to use the current store value in a derived store, as my derived store builds a set of results which need to be concatenated. I can work around it though, so:

low

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions