What’s the difference between fork and spawn in redux-saga?

One way to look at it is to see your saga’s as a Graph. ‘fork’ creates a child from the calling process. While ‘spawn’ creates a new child at the root of the graph.

So when you ‘fork’ another process, the parent process will wait until the ‘forked’ process is finished. Also every exception will bubble up from the child to the parent and can be caught in the parent.

A ‘spawned’ process though will not block the parent, so the next ‘yield’ statement is called immediately. Also the parent process will not be able to catch any exceptions that happen in the ‘spawned’ process.

I hope this was helpful.

Leave a Comment

tech