Skip to content

Commit

Permalink
Updated: Basic Setup examples in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed Sep 15, 2010
1 parent 7cc4025 commit f44279a
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,52 @@

});


## Basic Worker Example

importScripts('jquery.hive.pollen.js');

$(function (data) {

// `this` equals WorkerGlobalScope

$.ajax.get({
url: 'get-data-from-the-server.php',
dataType:'json',
data: $.param(data.message),
success: function(jsonObj) {

// Assume its a list of companies with some contact data.

$.send(
$.unique(
$.filter(jsonObj, function (obj) {
// If not passed in the data property above, we could filter here.
// Not the most efficient way, the example is really to illustrate Pollen's syntax

if ( $.inStr(obj.company, data.company) ) {
return true;
}
return false;
})
)
);

// OR...

$.send(
$.query(
// Get filtered data with a JSONPath query
"?company='"+data.company+"'",
jsonObj
)
);
}
});


});

0 comments on commit f44279a

Please sign in to comment.