I have a use-case where as soon as my API receive a request, then i need to make a call to some remote server to fetch the data as per id received in the request, run my processing on that data and populate a response value-object.
Now i need to do two things:
1) return this response value-object to the caller of my API which completes this flow in the same thread,
2) Also start an Async thread to update this response value-object(which is JSON) in Stringify manner to a cache . This second flow is of the style "fire and forget". Here I am planning to use observer pattern in second flow ( the Async one).So that means as soon the response value-object is formed, it will call the setValue(..) method of the OBSERVABLE class which will call its OBSERVER, and in the OBSERVER's Update() method i will start a new thread which will update the cache.
But someone was saying using observer here i am increasing the time of processing, but i feel using observer-pattern provides loose coupling and code-extandability. Do you feel the same that by using Observer pattern here i am increasing time of processing, if that is the case then i can start this new thread for Async processing in my API itself and not using Observer class to do that.
Lets me know your thoughts at your earliest so i can take it further.