PageRenderTime 54ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/_posts/2012-05-11-fluent-backbone-asq-lefunc.md

http://github.com/alexyoung/dailyjs
Markdown | 95 lines | 70 code | 25 blank | 0 comment | 0 complexity | d989c5f82a5146f4f01e2245ef5c0906 MD5 | raw file
Possible License(s): CC-BY-SA-3.0
  1. ---
  2. layout: post
  3. title: "Fluent, Backbone.xmpp, leFunc, Frisby"
  4. author: Alex Young
  5. categories:
  6. - conferences
  7. - events
  8. - xmpp
  9. - backbone.js
  10. ---
  11. ###Fluent Conference
  12. ![Fluent](/images/posts/fluent.png)
  13. [Fluent](http://fluentconf.com/fluent2012) will be held on May 29-31, in San Francisco. It features several tracks -- one covers [language issues](http://fluentconf.com/fluent2012/public/schedule/topic/830) and includes a session with Brendan Eich. The [browser track](http://fluentconf.com/fluent2012/public/schedule/topic/831) has talks from employees of social networking favourites Twitter, Facebook, and Twitter, and even Microsoft! There's also a track for [Node sessions](http://fluentconf.com/fluent2012/public/schedule/topic/832), which has speakers from Joyent, Twitter, Groupon, and lots more interesting companies.
  14. "Early price" tickets are on sale until May 15th, and there are several tiers available:
  15. * All-Access Pass: $1695 (standard price: $1895)
  16. * Conference Plus Tuesday Workshops: $1295 (standard price: $1495)
  17. * Conference: $995 (standard price: $1195)
  18. * Tuesday Workshops: $695 (standard price: $895)
  19. There are discounts for previous O'Reilly conference attendees, company teams, academic staff, non-profits, and students.
  20. ###Backbone.xmpp
  21. [Backbone XMPP Pub-Sub Storage](https://github.com/ggozad/Backbone.xmpp) (License: _MIT_) by Yiorgis Gozadinos is an alternative storage layer for [Backbone.js](http://documentcloud.github.com/backbone/) that uses [XMPP publish-subscribe](http://xmpp.org/extensions/xep-0060.html).
  22. To use it, set a collection's `sync` property to `Backbone.xmppSync`, and assign an instance of `PubSubStorage` to the collection's `node` property:
  23. {% highlight javascript %}
  24. var MyCollection = Backbone.Collection.extend({
  25. sync: Backbone.xmppSync
  26. , model: MyModel
  27. });
  28. var mycollection = new MyCollection();
  29. mycollection.node = new PubSubStorage('mymodels', connection);
  30. {% endhighlight %}
  31. The README has links to full documentation in the form of annotated source.
  32. ###leFunc
  33. [leFunc](https://github.com/jrf0110/leFunc) (License: _MIT_, npm: [leFunc](http://npmjs.org/package/leFunc)) by John Fawcett is a library that uses type checking to support function overloading in pure JavaScript:
  34. {% highlight javascript %}
  35. var getItems = leFunc({
  36. 'string'; function(id) {
  37. // Do something
  38. },
  39. 'string,object': function(id, options) {
  40. // Do something else
  41. },
  42. 'string,object,function': function(id, options, callback) {
  43. // Do something different
  44. callback();
  45. }
  46. });
  47. getItems('123abc'); // Calls the first function
  48. getItems('123abc', { awesome: true }); // Calls the second function
  49. getItems('123abc', { awesome: true }, function(){}); // Calls the third function
  50. {% endhighlight %}
  51. At the moment it'll work with any function signatures that are relatively easy to type check. That means [primitive values and objects](http://dailyjs.com/2012/05/07/js101-object/) will work as expected.
  52. ###Frisby
  53. If you're testing a lot of REST-based APIs, then [Frisby](http://frisbyjs.com/) (GitHub: [vlucas / frisby](https://github.com/vlucas/frisby), License: _BSD_, npm: [frisby](http://npmjs.org/package/frisby)) by Vance Lucas might be what you're looking for. It's a REST API testing framework built using [Jasmine](http://pivotal.github.com/jasmine/).
  54. It has a nice and friendly chainable API:
  55. {% highlight javascript %}
  56. var frisby = require('frisby');
  57. frisby.create('Get Brightbit Twitter feed')
  58. .get('https://api.twitter.com/1/statuses/user_timeline.json?screen_name=brightbit')
  59. .expectStatus(200)
  60. .expectHeaderContains('content-type', 'application/json')
  61. .expectJSON('0', {
  62. place: function(val) { expect(val).toMatchOrBeNull("Oklahoma City, OK"); }, // Custom matcher callback
  63. user: {
  64. verified: false,
  65. location: "Oklahoma City, OK",
  66. url: "http://brightb.it"
  67. }
  68. });
  69. {% endhighlight %}
  70. The project itself is also fully tested, and comes with [API documentation](http://frisbyjs.com/docs/api/).