From 5e622215ba099ba557832b8c2efeae1a9e97aa74 Mon Sep 17 00:00:00 2001 From: David Glasser Date: Sat, 15 Sep 2012 15:20:56 -0700 Subject: [PATCH] Change all publicly documented APIs to use camelCase. For now, the old names still work as well. This includes: - Meteor.isServer/isClient - this.isSimulation in methods - Context.onInvalidate - Meteor.status().retryCount/retryTime Remove old backwards-compatibility "Sky" alias for "Meteor". Update all examples in the docs to use camelCase. Delete unused docs/client/projects.html file. --- app/meteor/skel/~name~.js | 4 +- docs/client/api.html | 128 +++++++++--------- docs/client/api.js | 30 ++-- docs/client/concepts.html | 36 ++--- docs/client/docs.js | 8 +- docs/client/projects.html | 26 ---- examples/leaderboard/leaderboard.js | 4 +- .../template-demo/client/template-demo.js | 2 +- examples/unfinished/azrael/model.js | 2 +- examples/unfinished/todos-backbone/common.js | 2 +- .../unfinished/todos-underscore/common.js | 2 +- examples/wordplay/model.js | 4 +- packages/deps/deps.js | 2 +- packages/http/httpcall_tests.js | 8 +- packages/livedata/livedata_common.js | 7 +- packages/livedata/livedata_connection.js | 14 +- .../livedata/livedata_connection_tests.js | 2 + packages/livedata/livedata_server.js | 6 +- packages/livedata/livedata_test_service.js | 10 +- packages/livedata/livedata_tests.js | 38 +++--- packages/meteor/client_environment.js | 4 +- packages/meteor/client_environment_test.js | 4 +- packages/meteor/server_environment.js | 4 +- packages/meteor/server_environment_test.js | 4 +- packages/meteor/timers.js | 4 +- packages/minimongo/minimongo.js | 2 +- packages/mongo-livedata/collection.js | 4 +- .../mongo-livedata/mongo_livedata_tests.js | 22 +-- packages/past/client_past_test.js | 4 + packages/past/package.js | 9 ++ packages/past/past.js | 11 +- packages/past/server_past_test.js | 4 + packages/session/session.js | 4 +- packages/spark/spark.js | 8 +- packages/stream/stream_client.js | 26 +++- packages/stream/stream_tests.js | 3 + packages/test-helpers/onscreendiv.js | 2 +- packages/test-helpers/reactivevar.js | 2 +- packages/test-helpers/wrappedfrag.js | 2 +- packages/tinytest/tinytest.js | 4 +- 40 files changed, 239 insertions(+), 223 deletions(-) delete mode 100644 docs/client/projects.html create mode 100644 packages/past/client_past_test.js create mode 100644 packages/past/server_past_test.js diff --git a/app/meteor/skel/~name~.js b/app/meteor/skel/~name~.js index 2ce3a86c0a..fb93efc449 100644 --- a/app/meteor/skel/~name~.js +++ b/app/meteor/skel/~name~.js @@ -1,4 +1,4 @@ -if (Meteor.is_client) { +if (Meteor.isClient) { Template.hello.greeting = function () { return "Welcome to ~name~."; }; @@ -12,7 +12,7 @@ if (Meteor.is_client) { }; } -if (Meteor.is_server) { +if (Meteor.isServer) { Meteor.startup(function () { // code to run on server at startup }); diff --git a/docs/client/api.html b/docs/client/api.html index 67b29bdaf0..a6029b3685 100644 --- a/docs/client/api.html +++ b/docs/client/api.html @@ -10,8 +10,8 @@ available just on the client, just on the server, or *Anywhere*.

Meteor Core

-{{> api_box is_client}} -{{> api_box is_server}} +{{> api_box isClient}} +{{> api_box isServer}} {{> api_box startup}} On a server, the function will run as soon as the server process is @@ -20,7 +20,7 @@ is ready and any `` templates from your `.html` files have been put on the screen. // On server startup, if the database is empty, create some initial data. - if (Meteor.is_server) { + if (Meteor.isServer) { Meteor.startup(function () { if (Rooms.find().count() === 0) { Rooms.insert({name: "Initial room"}); @@ -46,7 +46,7 @@ will publish that cursor's documents. // server: publish the rooms collection, minus secret info. Meteor.publish("rooms", function () { - return Rooms.find({}, {fields: {secret_info: false}}); + return Rooms.find({}, {fields: {secretInfo: false}}); }); Otherwise, the publish function can set and unset @@ -68,7 +68,7 @@ Example: var uuid = Meteor.uuid(); var count = 0; - var handle = Messages.find({room_id: roomId}).observe({ + var handle = Messages.find({roomId: roomId}).observe({ added: function (doc, idx) { count++; self.set("counts", uuid, {roomId: roomId, count: count}); @@ -197,7 +197,7 @@ remotely by clients. They should return a value or throw an exception. Inside your method invocation, `this` is bound to a method invocation object, which provides the following: -* `is_simulation`: a boolean value, true if this invocation is a stub. +* `isSimulation`: a boolean value, true if this invocation is a stub. * `unblock`: when called, allows the next method from this client to begin running. @@ -214,7 +214,7 @@ intended to *simulate* the result of what the server's method will do, but without waiting for the round trip delay. If a stub throws an exception it will be logged to the console. -{{> api_box method_invocation_is_simulation}} +{{> api_box method_invocation_isSimulation}} {{> api_box method_invocation_unblock}} @@ -309,16 +309,16 @@ the server. The return value is an object with the following fields: new connection), and waiting (failed to connect and waiting to try to reconnect). -
retry_count +
retryCount Number
The number of times the client has tried to reconnect since the connection was lost. 0 when connected.
-
retry_time +
retryTime Number or undefined
The estimated time of the next reconnection attempt. To turn this into an interval until the next reconnection, use - retry_time - (new Date()).getTime(). This key will + retryTime - (new Date()).getTime(). This key will be set only when status is waiting.
@@ -381,13 +381,13 @@ compatible with the popular Mongo database API. The same database API works on both the client and the server (see below). // return array of my messages - var my_messages = Messages.find({user_id:Session.get('my_user_id')}).fetch(); + var myMessages = Messages.find({userId: Session.get('myUserId')}).fetch(); // create a new message Messages.insert({text: "Hello, world!"}); // mark my first message as "important" - Messages.update(my_messages[0].id, {$set: {important: true}}); + Messages.update(myMessages[0].id, {$set: {important: true}}); If you pass a `name` when you create the collection, then you are declaring a persistent collection — one that is stored on the @@ -537,9 +537,9 @@ undefined. If the insert is successful, `error` is undefined and Example: - var groceries_id = Lists.insert({name: "Groceries"}); - Items.insert({list: groceries_id, name: "Watercress"}); - Items.insert({list: groceries_id, name: "Persimmons"}); + var groceriesId = Lists.insert({name: "Groceries"}); + Items.insert({list: groceriesId, name: "Watercress"}); + Items.insert({list: groceriesId, name: "Persimmons"}); {{> api_box update}} @@ -620,9 +620,9 @@ the matching documents. Examples: // Print the titles of the five top-scoring posts - var top_posts = Posts.find({}, {sort: {score: -1}, limit: 5}); + var topPosts = Posts.find({}, {sort: {score: -1}, limit: 5}); var count = 0; - top_posts.forEach(function (post) { + topPosts.forEach(function (post) { console.log("Title of post " + count + ": " + post.title); count += 1; }); @@ -648,8 +648,8 @@ the matching documents. // Display a count of posts matching certain criteria. Automatically // keep it updated as the database changes. var frag = Meteor.render(function () { - var high_scoring = Posts.find({score: {$gt: 10}}); - return "

There are " + high_scoring.count() + " posts with " + + var highScoring = Posts.find({score: {$gt: 10}}); + return "

There are " + highScoring.count() + " posts with " + "scores greater than 10

"; }); document.body.appendChild(frag); @@ -672,29 +672,29 @@ query result. `callbacks` may have the following functions as properties:
-{{#dtdd "added(document, before_index)"}} +{{#dtdd "added(document, beforeIndex)"}} A new document entered the result set. It was inserted immediately before the document currently at the -position `before_index`. Or if it was inserted at the end -of the list, `before_index` will be equal to the (prior) +position `beforeIndex`. Or if it was inserted at the end +of the list, `beforeIndex` will be equal to the (prior) length of the list. {{/dtdd}} -{{#dtdd "changed(new_document, at_index, old_document)"}} -The contents of the document at position `at_index` -changed to `new_document`, was previously `old_document`. +{{#dtdd "changed(newDocument, atIndex, oldDocument)"}} +The contents of the document at position `atIndex` +changed to `newDocument`, was previously `oldDocument`. {{/dtdd}} -{{#dtdd "moved(document, old_index, new_index)"}} +{{#dtdd "moved(document, oldIndex, newIndex)"}} A document changed its position in the result set, -from `old_index` to `new_index`. For your +from `oldIndex` to `newIndex`. For your convenience, its current contents is `document`. (This will only fire immediately after `changed`. {{/dtdd}} -{{#dtdd "removed(old_document, at_index)"}} -The document at position `at_index`, which was previously -`old_document`, is no longer in the result set. +{{#dtdd "removed(oldDocument, atIndex)"}} +The document at position `atIndex`, which was previously +`oldDocument`, is no longer in the result set. {{/dtdd}}
@@ -710,7 +710,7 @@ Example: // Keep track of how many administrators are online. var count = 0; - var query = Users.find({admin: true, online_now: true}); + var query = Users.find({admin: true, onlineNow: true}); var handle = query.observe({ added: function (user) { count++; @@ -821,9 +821,9 @@ store an arbitrary set of key-value pairs. Use it to store things like the currently selected item in a list. What's special about `Session` is that it's reactive. If -you call [`Session.get`](#session_get)`("current_list")` +you call [`Session.get`](#session_get)`("currentList")` from inside a template, the template will automatically be rerendered -whenever [`Session.set`](#session_set) is called. +whenever [`Session.set`](#session_set)`("currentList", x)` is called. {{> api_box set}} @@ -867,33 +867,33 @@ These two expressions do the same thing: Example: -