Permalink
Browse files

Little fix to sync lib

  • Loading branch information...
1 parent 91933cd commit 1d6fb8b16a5601087af89825f8d3898f007d9c96 @zefhemel zefhemel committed Sep 26, 2010
Showing with 6 additions and 40 deletions.
  1. +0 −36 docs/DEVELOPMENT.md
  2. +2 −0 lib/persistence.sync.js
  3. +1 −1 test/test.persistence.js
  4. +3 −3 test/test.sync.server.js
View
@@ -41,39 +41,3 @@ Extension hooks
* `persistence.flushHooks`: a list of functions to be called before flushing.
* `persistence.schemaSyncHooks`: a list of functions to be called before syncing the schema.
-Idioms
-------
-
-Because persistence.js is an asynchronous library, a lot happens
-asynchronously (shocker). The way I typically handle an unknown
-sequence of asynchronous calls is as follows, I know it's expensive on
-the stack (it makes a lot of recursive calls), but it's the best I've
-been able to come up with.
-
-Let's say we have an array `myArray` of values and we have to invoke a
-function `someAsyncFunction` on each item sequentially. Except, the
-function is asynchronous, and thus does not return a value
-immediately, but instead has a callback that is called with the
-result. This is how I typically implement that in persistence.js, note
-that this destroys `myArray`, at the end the array is empty, so if you
-care about its value, `.slice(0)` it first.
-
- var myArray = [1, 2, 3, 4, 5];
-
- function processOne() {
- var item = myArray.pop(); // pop (last) item from the array
- someAsyncFunction(item, function(result) {
- // do something with result
- if(myArray.length > 0) {
- processOne();
- } else {
- // Do whatever you need when you're completely done
- }
- });
- }
-
- if(myArray.length > 0) {
- processOne();
- } else {
- // Do whatever you need when you're completely done
- }
View
@@ -56,6 +56,8 @@ persistence.sync.postJSON = function(uri, data, callback) {
(function() {
+ var argspec = persistence.argspec;
+
persistence.sync.Sync = persistence.define('_Sync', {
entity: "VARCHAR(255)",
service: "VARCHAR(255)",
View
@@ -531,7 +531,7 @@ $(document).ready(function(){
persistence.add(tag);
tags.push(tag);
}
- for(var i = 0; i < 1000; i++) {
+ for(var i = 0; i < 10; i++) {
var task = new Task({name: "Task " + i});
task.done = true;
task.tags = new persistence.LocalQueryCollection(tags);
View
@@ -32,9 +32,9 @@ var sys = require('sys');
var connect = require('connect');
var express = require('express');
-var persistence = require('../persistence').persistence;
-var persistenceStore = require('../persistence.store.mysql');
-var persistenceSync = require('../persistence.sync.server');
+var persistence = require('../lib/persistence').persistence;
+var persistenceStore = require('../lib/persistence.store.mysql');
+var persistenceSync = require('../lib/persistence.sync.server');
// Database configuration
persistenceStore.config(persistence, 'localhost', 'synctest', 'test', 'test');

0 comments on commit 1d6fb8b

Please sign in to comment.