From ee3bd696fe987abb2601d3afdc85b88c8cbb80ea Mon Sep 17 00:00:00 2001 From: Nick Martin Date: Wed, 29 Aug 2012 17:13:57 -0700 Subject: [PATCH] Move flush to deps. Not the best place for it, but better than core. --- docs/client/api.html | 64 +++++++++++++++++++++++--------------------- docs/client/api.js | 30 ++++++++++----------- docs/client/docs.js | 6 ++--- 3 files changed, 52 insertions(+), 48 deletions(-) diff --git a/docs/client/api.html b/docs/client/api.html index 43298452cf..14d9cd2d38 100644 --- a/docs/client/api.html +++ b/docs/client/api.html @@ -28,36 +28,6 @@ put on the screen. }); } -{{> api_box flush }} - -Normally, when you make changes (like writing to the database), -their impact (like updating the DOM) is delayed until the system is -idle. This keeps things predictable — you can know that the DOM -won't go changing out from under your code as it runs. It's also one -of the things that makes Meteor fast. - -`Meteor.flush` forces all of the pending reactive updates to complete -(for example, it ensures the DOM has been updated with your recent -database changes.) Call `flush` to apply those pending changes -immediately. The main use for this is to make sure the DOM has been -brought up to date with your latest changes, so you can manually -manipulate it with jQuery or the like. - -When you call `flush`, any auto-updating DOM elements that are not on -the screen may be cleaned up (meaning that Meteor will stop tracking -and updating the elements, so that the browser's garbage collector can -delete them.) So, if you manually call `flush`, you need to make sure -that any auto-updating elements that you have created by calling -[`Meteor.ui.render`](#meteor_ui_render) have already been inserted in the main -DOM tree. - -Technically speaking, `flush` calls the [invalidation -callbacks](#on_invalidate) on every [reactive context](#context) that -has been [invalidated](#invalidate), but hasn't yet has its callbacks -called. If the invalidation callbacks invalidate still more contexts, -flush keeps flushing until everything is totally settled. The DOM -elements are cleaned up because of logic in -[`Meteor.ui.render`](#meteor_ui_render) that works through invalidations.

Publish and subscribe

@@ -1683,6 +1653,40 @@ just means that [`run`](#run) sets it, runs some user-supplied code, and then restores its previous value.) +{{> api_box flush }} + +Normally, when you make changes (like writing to the database), +their impact (like updating the DOM) is delayed until the system is +idle. This keeps things predictable — you can know that the DOM +won't go changing out from under your code as it runs. It's also one +of the things that makes Meteor fast. + +`Meteor.flush` forces all of the pending reactive updates to complete +(for example, it ensures the DOM has been updated with your recent +database changes.) Call `flush` to apply those pending changes +immediately. The main use for this is to make sure the DOM has been +brought up to date with your latest changes, so you can manually +manipulate it with jQuery or the like. + +When you call `flush`, any auto-updating DOM elements that are not on +the screen may be cleaned up (meaning that Meteor will stop tracking +and updating the elements, so that the browser's garbage collector can +delete them.) So, if you manually call `flush`, you need to make sure +that any auto-updating elements that you have created by calling +[`Meteor.render`](#meteor_render) have already been inserted in the main +DOM tree. + +Technically speaking, `flush` calls the [invalidation +callbacks](#on_invalidate) on every [reactive context](#context) that +has been [invalidated](#invalidate), but hasn't yet has its callbacks +called. If the invalidation callbacks invalidate still more contexts, +flush keeps flushing until everything is totally settled. The DOM +elements are cleaned up by logic that is triggered by context invalidations. + + + + +

Meteor.http

`Meteor.http` provides an HTTP API on the client and server. To use diff --git a/docs/client/api.js b/docs/client/api.js index b76a299027..a543f7df47 100644 --- a/docs/client/api.js +++ b/docs/client/api.js @@ -24,14 +24,6 @@ Template.api.startup = { ] }; -Template.api.flush = { - id: "meteor_flush", - name: "Meteor.flush()", - locus: "Client", - descr: ["Ensure that any reactive updates have finished. Allow auto-updating DOM element to be cleaned up if they are offscreen."] -}; - - Template.api.publish = { id: "meteor_publish", name: "Meteor.publish(name, func)", @@ -483,13 +475,6 @@ Template.api.Context = { descr: ["Create an invalidation context. Invalidation contexts are used to run a piece of code, and record its dependencies so it can be rerun later if one of its inputs changes.", "An invalidation context is basically just a list of callbacks for an event that can fire only once. The [`on_invalidate`](#on_invalidate) method adds a callback to the list, and the [`invalidate`](#invalidate) method fires the event."] }; -Template.api.current = { - id: "current", - name: "Meteor.deps.Context.current", - locus: "Client", - descr: ["The current [`invalidation context`](#context), or `null` if not being called from inside [`run`](#run)."] -}; - Template.api.run = { id: "run", name: "context.run(func)", @@ -521,6 +506,21 @@ Template.api.invalidate = { descr: ["Add this context to the list of contexts that will have their `on_invalidate|on_invalidate` callbacks called by the next call to [`Meteor.flush`](#meteor_flush)."] }; +Template.api.current = { + id: "current", + name: "Meteor.deps.Context.current", + locus: "Client", + descr: ["The current [`invalidation context`](#context), or `null` if not being called from inside [`run`](#run)."] +}; + +Template.api.flush = { + id: "meteor_flush", + name: "Meteor.flush()", + locus: "Client", + descr: ["Ensure that any reactive updates have finished. Allow auto-updating DOM element to be cleaned up if they are offscreen."] +}; + + // writeFence // invalidationCrossbar diff --git a/docs/client/docs.js b/docs/client/docs.js index b45801eac8..f6e8710d24 100644 --- a/docs/client/docs.js +++ b/docs/client/docs.js @@ -82,8 +82,7 @@ var toc = [ "Core", [ "Meteor.is_client", "Meteor.is_server", - "Meteor.startup", - "Meteor.flush" + "Meteor.startup" ], "Publish and subscribe", [ @@ -181,7 +180,8 @@ var toc = [ {instance: "context", name: "on_invalidate"}, {instance: "context", name: "invalidate"} ], - {name: "Meteor.deps.Context.current", id: "current"} + {name: "Meteor.deps.Context.current", id: "current"}, + "Meteor.flush" // ], // "Environment Variables", [