❶ 人間正道是滄桑 楊立青要娶瞿霞為什麼說自己死了

那個年月幹部結婚是有條件的,老穆說要師以上幹部才能結婚說的內就是條件。楊力青當時不符合容這個條件。但是他對自己很有信心,肯定自己如果活著的話以後肯定不止是個師長。後面的劇情也表示他至少是少將軍長。所以他對老穆說的意思是我是有條件結婚的。

❷ 如何理解 Meteor 所提出的 Optimistic UI

作者:立青
鏈接:http://www.hu.com/question/40128898/answer/89205432
來源:知乎
著作權歸作者所有。商業轉載請聯系作者獲得授權,非商業轉載請註明出處。

In this post we』ll look at the collection of technologies that Meteor provides to enable 『Optimistic UI』 updating. This capability is crucial to user expectations for modern web apps and is fundamental to Meteor.
在這篇博文中,我們就來看看 Meteor 為實現「積極 UI 更新」所提供的一系列技術。從用戶對於現代 web 應用的期望來說,這種能力非常重要,而這在 Meteor 當中也是最基本的。
Meteor is a full-stack JavaScript platform with default technologies for every layer of the stack, starting with the database and ending with reactive UI re-rendering. You can swap these technologies out to suit your preference; for instance you can exchange the default Blaze front-end for React, Angular, or a native iOS front-end.
Meteor 是一個全棧 JavaScript 平台,在從資料庫到響應式 UI 渲染的每一層技術架構上,都提供了默認的解決方案。當然你也可以將其替換成適合於自己的選擇,比如說你可以將默認的 Blaze 前端換成 React,Angular,或者是原生的 iOS 前端。
But there』s one part that represents the core of the Meteor platform: full-stack data integration with DDP, LiveQuery, and Minimongo. In this case the full-stack integration provides real value that would be hard to rebuild from separate components. Let me tell you why.
但本文所討論的這部分則代表著 Meteor 平台的核心:使用 DDP,LiveQuery,Minimongo 進行構建的全棧數據集成方案。在這種情況下,全棧集成方案則提供了難以對單獨的部分重新進行構建的真正價值。就讓我來告訴你為什麼。

TL;DR | 「Too long; didn』t read」 / 太長不讀版

Your app should be able to respond to user inputs faster than it takes to make a whole roundtrip to the server — we call this Optimistic UI updating. It』s very hard to build an app that correctly implements client-side simulations as it takes a lot of work to make your UI consistent, avoid loading plicate data over and over, and keep your client up to date with your server data. Keep reading to see why you need this, why it』s hard and how Meteor makes it easy.
你的應用應當更快地響應用戶輸入,而不是等待它從伺服器完成了整個來回 —— 我們稱之為 Optimistic UI 更新(此文均譯為「積極的 UI」)。構建應用時,正確模擬客戶端實現是非常困難的,因為這需要大量工作來保持 UI 一致、避免重復數據載入、以及保持客戶端與伺服器端之間的數據更新。繼續看下去,你就知道為什麼需要這樣做,又為何如此之難,以及 Meteor 是如何使之變得容易。

Users of modern web apps expect the UI to respond instantly | 用戶期望現代 web 應用 UI 能夠即時響應

When a user pushes a button in a website or a mobile app, they don』t want to wait for a request to be sent all the way to the server to calculate the new state of the screen. Using the basic AJAX model of calculating the results on the server and then displaying them to the user will cause your app to feel laggy, and sometimes inconsistent with the user』s input. Mobile developers especially need to worry about this because cellular networks can be unreliable, sometimes taking a second or more to deliver a result from your server.
當用戶點擊了網站或者移動應用的按鈕之後,他們並不想要等待一個請求發送至伺服器進行計算之後,再從屏幕上看到新的狀態。使用基礎的 AJAX 模型,需要在伺服器端進行計算後才能夠顯示給用戶,這會導致你的應用感覺滯後,並且有時還會出現與用戶輸入不一致的情況。對移動開發者來說,尤其需要擔心這種問題,因為移動網路的穩定性較差,所以從伺服器端返回結果,有時需要花上一秒甚至更長時間。
There are four elements required to satisfy this expectation and requirement. Let』s explore those.

滿足以上期望和需求的四個必要元素如下,讓我們來探究一下:

1. To have your app respond instantly, you need to render the UI on the client | 為了應用即時響應,需要在客戶端渲染 UI

This is one explanation for the rise of client-side rendering frameworks like Angular and React — you need to be able to compute your HTML directly in the browser to be able to update the view without doing a round trip to the server. Whenever the user takes an action, you need to first update your UI to make things look fast, then send a request to the server to do that modification on the real database. At Meteor, we call this Optimistic UI, or latency compensation.
這是 Angular 和 React 等客戶端渲染框架興起的一種解釋 —— 你需要在瀏覽器中直接計算 HTML,而不是從伺服器端重新走了一圈再來更新視圖。無論何時用戶觸發了一個操作,你需要優先更新 UI 使之看起來反應迅速,然後再發送給伺服器端去做真正的資料庫修改操作。在 Meteor 中,我們稱之為「積極的 UI」,或者是延時補償。
In order to make optimistic updates and be able to predict the state of the UI after some user action, you will need to keep some of your application data on the client.
為了達到「積極更新」,並且能夠預測用戶操作後的 UI 狀態,你需要在客戶端保存一些應用數據。
One option is to directly store things inside the front-end framework』s local state — Angular『s $scope or React』s component state — but you can imagine how this would easily result in plication of data or inconsistency. If you have two widgets on the page showing the same data in different ways, then they will each have one of the data, and worse those copies might not be consistent. Having two UI elements on your page showing inconsistent results sounds like a great way to end up with confused users.
其中一種選項就是直接將其存儲到前端框架的本地狀態當中 —— 比如 Angular 的 $scope 或者是 React 的組件狀態 —— 但可想而知,這很容易就會導致數據的重復和不一致。如果你在同一頁面的兩個地方分別使用不同的方式顯示相同的數據,然後他們都會有這個數據的一份拷貝,更糟糕的是這些拷貝很可能不一致。在頁面上擁有兩個顯示不同結果的 UI 元素,這會使用戶非常困惑,從而導致用戶流失。
So what』s the solution - how do we keep all of our UI state de-plicated and internally consistent?
所以何來解決之道 —— 我們如何讓所有的 UI 狀態避免重復並且保證本質的一致性?

2. To have your UI consistent and avoid data plication, you need a global data cache on the client | 為了保持 UI 一致,避免數據重復,客戶端需要全局數據緩存

If you want your UI to be consistent and avoid lo www.hbbz08.com ading the same data sets over and over again, you need to render everything from the same data source. When you make some action on the page and update this global data source, that can trigger updates in all of the relevant UI elements on the page to keep everything consistent. It』s almost like magic — you can update your whole UI before you even hit the server.
如果你想要 UI 保持一致,並且避免相同數據集的反復載入,則需要從同一數據源渲染所有東西。當你在頁面上觸發了某些操作,就會更新全局的數據源,那麼這些數據就會觸發頁面上所有的相關 UI 元素進行更新,從而使一切都保持一致性。這就像魔法一樣 —— 你可以在連接伺服器之前就更新了整個 UI。

Minimongo is Meteor』s single source of truth for the client | Minimongo 就是 Meteor 在客戶端上單一數據源的真相

Meteor is the only framework that includes a first-class solution for this problem, and it』s called Minimongo. The same way that your database is a single source of truth for your server, Minimongo is a single source of truth for the client. If you have two widgets that display overlapping data, you can render them both from a reactive query on this client-side database and they are guaranteed to be consistent.
Meteor 是唯一的框架對此問題提供了一流的解決方案,稱之為 Minimongo。與此同時,資料庫則是在伺服器端的單一真實數據源,而 Minimongo 則是客戶端的單一真實數據源。如果你有兩個用於顯示相同數據的部件,你可以從客戶端資料庫的響應式查詢中同時渲染這兩部分,兩者的結果必然是一致的。

Run the same queries on the client and server | 在客戶端和伺服器端執行相同的查詢操作

As you might be able to tell from the name, Minimongo uses a direct clone of MongoDB』s query language to client-side JavaScript. This is nice because you can use the same code on the client and the server to get and update your data, making it even easier to write optimistic UI update code. Meteor has had this component since day one — it』s a core part of how Meteor』s magic works.
可能你已經從名字中猜到,Minimongo 在客戶端 JavaScript 中直接使用了與 MongoDB 完全相同的查詢語言。這非常棒,因為你可以在客戶端和伺服器端使用同樣的代碼來獲取和更新數據,這使得編寫 「積極 UI 更新」的代碼變得更加容易。Meteor 自打第一天開始就擁有了這個部件 —— 這是 Meteor 魔法如何工作的一個核心部分。

3. To populate your data cache, you need a protocol for data subscriptions | 為了實現數據緩存,需要數據訂閱協議

Now that you know you need to put some of our data in a local cache on the client, you need a way to get it there and keep it up to date. This is where another core part of Meteor comes in — data subscriptions over DDP, Meteor』s data synchronization protocol.
既然你知道需要將數據放入客戶端的本地緩存當中,那麼就需要一種方式從中獲取數據,並使其保持更新。這是 Meteor 誕生的另一個核心部分 —— 建立於 DDP 之上的數據訂閱,Meteor 的數據同步協議。
When a new part of your application is displayed, it can request data to be loaded by registering a subscription, which is a request to the server to send over some data and put it into Minimongo on the client. Now, you can just render your UI components from Minimongo, and trust that the correct data will be there as soon as it is loaded. When the data is no longer needed, you can just unsubscribe and it will go away.
當你的應用程序顯示一個新的部分時,它可以通過注冊一個訂閱來請求數據。這將會發送請求給伺服器端並返回一些數據,然後將其放入客戶端的 Minimongo 當中。現在,你就可以直接從 Minimongo 中渲染 UI 組件了,相信正確的數據只要一被載入就會出現在那裡。而當你這些數據不再需要的時候,你只需要取消訂閱,它也就會隨之消失。

Subscriptions in Meteor have some awesome features:
They de-plicate data. You will never end up with two copies of the same data inside Minimongo.
They deliver realtime updates. You don』t have to manually poll or ask for updates; when new data shows up on the server, it will be automatically delivered to all of the clients that have subscribed to it.
Meteor 中的訂閱有一些非常棒的特性:
沒有重復數據。你就不用在 Minimongo 中存儲相同數據的兩份拷貝了。
實現實時更新。你不再需要手動檢查或請求更新;每當