salsita / redux-side-effects

Redux toolset for keeping all the side effects inside your reducers while maintaining their purity.
MIT License
180 stars 9 forks source link

Why do you use generators? #16

Open vojtatranta opened 8 years ago

vojtatranta commented 8 years ago

Why do you use generators if they compile into while loops? Is it not too early to use them? Have you encountered any troubles with that?

tomkis commented 8 years ago

We are using Generators because it's great construct which allows us nicely yield side effects within functions while hypothetically maintaining their purity. Even Redux attempted to utilize something similar https://github.com/reactjs/redux/issues/1528

We haven't encountered any problems while using Generators. It does have a drawback though, you can't yield effects within callbacks unless you explicitly provide yield* in the Functor. So for example traditional map with yield will not work.

Generators are actually pretty mature, they successfully made it into ES2015 and therefore will get natively supported in browsers soon.