Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is the expected behavior, though it is a little subtle, and not guaranteed (just an implementation detail).</p> <p>The callback to observe fires immediately when the command is inserted into <code>CommandQueue</code>. So the insert to <code>OtherCollection</code> happens while the <code>CommandQueue.insert</code> method is running, as part of the same call stack. This means the <code>OtherCollection</code> insert is considered part of the local 'simulation' of the <code>CommandQueue</code> insert, and is not sent to the server. The server runs the <code>CommandQueue</code> insert and sends the result back, at which point the client discards the results of the simulation and applies the results sent from the server, making the <code>OtherCollection</code> change disappear.</p> <p>A better way to do this would be to write a custom method. Something like:</p> <pre><code>Meteor.methods({ auditedCommand: function (command) { CommandQueue.insert(command); var whatever = someProcessing(command) OtherCollection.insert(whatever); } }); </code></pre> <p>Then:</p> <pre><code>Meteor.call('auditedCommand', command); </code></pre> <p>This will show up immediately on the client (latency compensation) and is more secure as clients can't insert to <code>CommandQueue</code> without also adding to <code>OtherCollection</code>.</p> <p><strong>EDIT</strong>: this will probably change. The added callback shouldn't really be considered part of the local simulation of CommandQueue.insert. Thats just the way it works now. That said, a custom method is probably still a better approach for this, it will work even if other people add commands to the command queue, and is more secure.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload