Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Reassigning an observable throws TypeError: $$unsubscribe_observableName is not a function #781

Closed
bvl12 opened this issue Jul 1, 2019 · 3 comments

Comments

@bvl12
Copy link

bvl12 commented Jul 1, 2019

When using rxjs' observables, they cannot be reassigned without throwing TypeError: $$unsubscribe_observableName is not a function. A minimal example can me found here: https://github.com/bvl12/sapper-observable-error

I know it is preferable to assign observables as constants, but my use case involves getting data from a database, which is not available until onMount and using autosubscriptions with it. I need to initialize the variable that will hold the observable with the data as another observable to prevent svelte from throwing me observableName is not a store with a 'subscribe' method

@Conduitry
Copy link
Member

Conduitry commented Jul 2, 2019

If you're talking about this, then dynamic imports return a promise resolving to the module, not the module itself. observableCreator.myObservable is going to be undefined. Use (await import('../observableCreator.js')).default.

@bvl12
Copy link
Author

bvl12 commented Jul 2, 2019

That import has actually been working fine for me (and showing what I expected when I print them). The issue I am having is that trying to overwrite an rxjs observable throws TypeError: $$unsubscribe_observableName is not a function (as it is trying to overwrite the old one), which is making me think that svelte is having an issue unsubscribing at the end of the autosubscription's lifecycle.

@bvl12
Copy link
Author

bvl12 commented Jul 2, 2019

closing because this isn't an issue with sapper, and the thread Conduitry linked above is more on-topic.

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

No branches or pull requests

2 participants