Traits with ES7 Decorators

es7 traits-decorator babel decorator bind-operator
03 Jul 2015

In this post we are going to explore how to use ES7 features to define traits with a brand new module: traits-decorator.

Read More

CocktailJS v0.7.0 Released

release
04 Mar 2015

A new version of CocktailJS! CocktailJS v0.7.0 is available on npm! As with all other releases, we try to keep all functionality backward compatible until the very first of 1.0 is released.

Read More

Using Cocktail In Your Current Project

javascript oop traits
27 Sep 2014

CocktailJS is a very versatile library. You can follow the single argument class definition where you can define your properties and methods, extend from another class, mix traits and export the class all in one single operation. But sometimes you already have a module definition where you want to keep the current code style. In this post we are going to explore how to use Traits or Talents in an exisiting class definition.

Read More

Properties & Non Primitive Values

javascript oop properties
11 Dec 2013

JavaScript has five primitive data types: String, Number, Boolean, Null and Undefined. All of these are inmutable, meaning that their values cannot be changed, while Objects, Array, Date, and others are mutable.

This post is intended to show a very subtle difference while defining properties values for a Class inside a prototype versus in the constructor.

TL;DR Do not define mutable properties (Object, Array, Date, etc) in the prototype.

Read More

CocktailJS v0.5.0 Released

release
28 Nov 2013

We are happy to announce a new version of CocktailJS! CocktailJS v0.5.0 is available on npm!

#A new version and more! With this new release we added more functionality to cocktail by adding a new way to create, use and share custom annotations. We also improved the code by refactoring some internals to avoid duplicated code, fixed some issues and we have added some tests too. But that’s not all. We have created a few CocktailJS Extensions and you can expect more of them to be released in a near future.

Read More

EventEmitter as Delegate using Traits

traits node javascript
11 Oct 2013

One of the most used modules in NodeJS is events. This module exposes a class called EventEmitter that allows you to listen to events in your application using the on or addListener methods. You can, as well, emit or fire your own custom events using emit.

Commonly, you would create an instance of EventEmitter or you could extend from it when you want to give your class the ability to listen to or fire events.

Read More

Refactoring Test Helper Methods with Talents

talents node javascript
24 Jul 2013

We consider tests mandatory in CocktailJS repository, not only unit tests but integration tests as well. And with those tests we found ourselves having to create some test helper methods to create some possible scenarios and restore state for example. We added some comments in lib/cocktail.js file as a friendly reminder that those methods should go away when we find a better design or strategy.

Read More

Why Annotations?

annotations node javascript
06 Apr 2013

#It’s all about describing code

An annotation is a note that is made while reading any form of text.

Annotations are used as a special form of syntactic metadata in the source code. The term metadata refers to “data about data”. While it is an ambiguous definition, the concept in CocktailJS is used to describe actions performed over a class or object . We need “metadata” to perform those actions but at the same time they describe -or annotate- the code.

Read More