abstract-object
Advanced tools
Comparing version 2.1.2 to 2.1.3
{ | ||
"name": "abstract-object", | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"description": "AbstractObject with Object State Events Support", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/snowyu/abstract-object", |
@@ -13,3 +13,8 @@ ### AbtractObject [![Build Status](https://img.shields.io/travis/snowyu/abstract-object/master.png)](http://travis-ci.org/snowyu/abstract-object) [![npm](https://img.shields.io/npm/v/abstract-object.svg)](https://npmjs.org/package/abstract-object) [![downloads](https://img.shields.io/npm/dm/abstract-object.svg)](https://npmjs.org/package/abstract-object) [![license](https://img.shields.io/npm/l/abstract-object.svg)](https://npmjs.org/package/abstract-object) | ||
+ add the state-able ability to any class. | ||
- **<broken change>**move RefObject to [ref-object](https://github.com/snowyu/ref-object.js) | ||
- **<broken change>** move RefObject to [ref-object](https://github.com/snowyu/ref-object.js) | ||
* decoupled the abstract-object completely. | ||
* All parts can be used individually. | ||
* stateable = require('abstract-object/ability') | ||
* eventable = require('events-ex/eventable') | ||
* refCountable = require('ref-object/ability') | ||
@@ -90,2 +95,4 @@ ## V2.x | ||
RefObject has moved to [ref-object](https://github.com/snowyu/ref-object.js) | ||
The `RefObject` is derived from AbstractObject. and add the `RefCount` and `AddRef/Release` Supports. | ||
@@ -104,10 +111,12 @@ | ||
AbstractObject = require('abstract-object') | ||
RefObject = require('abstract-object/RefObject') | ||
inherits = require('inherits-ex') | ||
createObject = AbstractObject.createObject | ||
createObject = AbstractObject.create | ||
#or createObject = require('inherits-ex/lib/createObject') | ||
class MyObject | ||
inherits MyObject, RefObject | ||
initialize: (@a,@b)-> | ||
super | ||
inherits MyObject, AbstractObject | ||
initialize: (@a, @b)-> | ||
@cache = {} | ||
finalize: -> | ||
@cache = null | ||
@@ -126,4 +135,5 @@ myObj = createObject(MyObject, 1, 2) | ||
initialize: (@a,@b)-> | ||
# must call super method here for RefObject initialization: | ||
super | ||
@cache = {} | ||
finalize: -> | ||
@cache = null | ||
@@ -137,5 +147,6 @@ ``` | ||
var AbstractObject = require('abstract-object') | ||
var RefObject = require('abstract-object/RefObject') | ||
var RefObject = require('ref-object') | ||
var inherits = require('inherits-ex') | ||
var createObject = AbstractObject.createObject | ||
var createObject = AbstractObject.create | ||
//or var createObject = require('inherits-ex/lib/createObject') | ||
@@ -147,3 +158,3 @@ //if you do not wanna to use the 'AbstractObject.create'(createObject): | ||
} | ||
// or, this MUST use 'AbstractObject.create' | ||
// or, this MUST use the 'AbstractObject.create'(createObject) | ||
var MyObject = function(){} | ||
@@ -156,8 +167,10 @@ | ||
MyObject.prototype.initialize = function(a,b) { | ||
//super call | ||
MyObject.__super__.initialize.call(this) | ||
this.a = a | ||
this.b = b | ||
this.cache = {} | ||
} | ||
MyObject.prototype.finalize = function() { | ||
this.cache = null | ||
} | ||
@@ -164,0 +177,0 @@ var myObj = createObject(MyObject, 1, 2) |
59270
267