Show helpful error message when calling writable() unsubscribe twice

pull/8186/head
Ben Bucksch 4 years ago
parent 3b3e1c839c
commit d14efa3760

@ -99,6 +99,9 @@ export function writable<T>(value?: T, start: StartStopNotifier<T> = noop): Writ
return () => {
subscribers.delete(subscriber);
if (subscribers.size === 0) {
if (stop === null) {
throw new Error('unsubscribe cannot be called twice');
}
stop();
stop = null;
}

Loading…
Cancel
Save