meteor/meteor — pull request #1901 by justinsb (2014-03-08 17:49:30+00:00)
Title: Generate ids consistently by passing a seed value in RPC calls

When an RPC call inserts an object, the client and the server will generate different random ids when they are executing the call. This causes flicker in the UI (the client display the locally generated item, which is then replaced by the server generated item). It can cause bigger problems if the id is e.g. used as the parent id for child objects.

Instead, we can ensure that the client and the server generate the same IDs for objects, by passing a seed value in the RPC call. This seed value is used to seed the random generator, so the client and the server will generate the same values.

We actually combine the seed from the RPC with the name of the collection, and keep track of that random sequence. In this way, we're able to tolerate inserting objects in different orders as long as they in different collections. (We can't currently tolerate reordering operations on the same collection though)