我一直在阅读有关 React 和 Redux 的内容,他们提到了“通用应用程序”。例如:
"You’ll probably want a (de)serialization mechanism for writing universal apps and hydrating their state from the server..." (From http://rackt.org/redux/docs/introduction/PriorArt.html)
什么是通用应用程序?
最佳答案
在此上下文中,通用应用程序是指能够根据情况在服务器或客户端中呈现的 Web 应用程序。
有时也可以称为“同构应用程序”。
更完整的解释来自https://www.npmjs.com/package/webpack-isomorphic-tools :
What is a web application? I would define it as a box with a bunch of inputs (keyboard events, mouse events) and a display as an output. A user walks into your website and your web application renders a "page" on his display.
At first all the rendering used to happen on the server. But then "AJAX" came (in 2005) and it opened a possibility of moving all rendering logic to the client (user's web browser) leaving the server with just serving API calls (data fetching, data modification, etc).
And so numerous javascript frameworks emerged to serve the purpose of client side rendering and routing. But then everybody realised that this new way of building web applications broke search engine indexing because the search engines didn't talk any javascript.
Then the age of super-responsive websites came and also the iPhone emerged and the battle for milliseconds began. And everybody noticed that client side rendering introduced unnecessary data fetching roundtrips on the first page load: the web browser loaded markup templates and scripts first and then asked the server for the actual data to display.
So it became obvious that web applications need to be "isomorphic" ("universal"), i.e. be able to render both on the client and the server, depending on circumstances. It was quite manageable: one just had to write the rendering logic in such a programming language that is able to run both on client and server. One such language is javascript.
关于reactjs - 什么是 "universal app"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33610399/