GuillaumeCisco / redux-sagas-injector

Helper for loading sagas asynchronously using redux
MIT License
69 stars 7 forks source link

How to remove an injected saga? #2

Closed gajus closed 6 years ago

gajus commented 6 years ago

I want to be able to inject saga when view mounts and eject it when view unmounts.

Is there a technical reason there is no method to eject a saga?

GuillaumeCisco commented 6 years ago

Hello @gajus, sorry for the delay, I didn't receive the notifications about issues.

Currently you cannot eject a saga. When you include a saga, it loads it from the web (code splitting), and register it in a registry. The registry is only a key:value object. So ejecting it, would simply remove this entry. Do you think it is really needed? The code of the saga will still live in your ram client.

gajus commented 6 years ago

This is less about removing the saga and more about stopping it.

You are right, properly removing saga would require use of WeakMap to register sagas in the first place.

Meanwhile, start/ stop control can be implemented at the saga level.