Adding onsuccess handler for EventSource and a fold function.