javascript - How to sleep within a saga, while supporting yields and cancling of forks -
i have generator, used in saga, suppose mock process of querying backend data. need mock able sleep second or 2 between put() calls emulate delay associated each tcp request.
i want mock generator support testing of generic logic designed used across multiple uis developing. includes tasking handler take generic data-loading generator, , return saga method take() appropriate actions , handle starting, stopping, , retasking generator based off of actions received.
this means mock saga needs 'feel' real saga, meaning must take long time complete, yield during dead time, , cancelable, if it's going serve test logic designed work on real populate method.
i can't seem this. promise insufficient since can't call yield() within .then() of promise. in addition i'm not if promise stooped when call cancel (from redux-saga) on forked generator.
i looked es6-sleep promised wanted, didn't seem sleep when used generator example.
how can emulate delay within generator?
Comments
Post a Comment