Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It's better for testing.


That's an unjustified excuse. The one thing that is consistent with UI programming among all platforms is that you never block the UI thread.

You should be able to mock fetch/xmlhttprequest at any point, not just in your router. You should be able to mock those calls without needing to block the UI thread at runtime.


No it's not. If you have to mock things like that it's a sign of poorly designed, stateful objects.


You mean unit testing? How so? I have never seen unit tests make real HTTP requests; it's much better to mock them. And changing from async to sync code for unit tests sounds like a bad idea, since you're not testing your code the way it actually works in production.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: