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

cleanup is not a function #2780

Closed
Rich-Harris opened this issue May 16, 2019 · 1 comment · Fixed by #2781
Closed

cleanup is not a function #2780

Rich-Harris opened this issue May 16, 2019 · 1 comment · Fixed by #2781
Labels

Comments

@Rich-Harris
Copy link
Member

If a deriver returns a non-falsy value, Svelte assumes it is a function, even if it isn't. This causes problems with e.g. async derivers:

const foo = writable(1);

// the deriver returns a promise
const bar = derived(foo, async ($foo, set) => {
  set($foo * 2);
});

Demo

@loilo
Copy link

loilo commented May 16, 2019

This has created some headaches for me as well yesterday — not even because I used async functions but because I tried mixing up return value with set(value). It should probably be explicitely documented that accepting the set parameter is mutually exclusive with returning a derived value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants