updated mixin docs and added .mixinAfter(..)...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-07-02 20:25:40 +03:00
parent c8f2477c19
commit a59bd98abf
2 changed files with 17 additions and 3 deletions

View File

@ -1284,6 +1284,9 @@ module.MetaActions = {
// in the inheritance chain... // in the inheritance chain...
// //
mixin: function(from, options){ mixin: function(from, options){
options = options || {}
options.source_tag = options.source_tag || from.__mixin_tag
var proto = Object.create(this.__proto__) var proto = Object.create(this.__proto__)
// mixinto an empty object // mixinto an empty object
@ -1302,6 +1305,16 @@ module.MetaActions = {
return this return this
}, },
// Mixin from after target in the mro...
//
// NOTE: target must be .getMixin(..) compatible...
mixinAfter: function(target, from, options){
this
.getMixin(target)
.mixin(from, options)
return this
},
// Mixin a set of local actions into an object... // Mixin a set of local actions into an object...
// //
// XXX this will not work on non-actions... // XXX this will not work on non-actions...
@ -1309,7 +1322,6 @@ module.MetaActions = {
return this.mixin.call(to, this, options) return this.mixin.call(to, this, options)
}, },
// Remove mixed in actions from this... // Remove mixed in actions from this...
// //
// NOTE: this will only remove local actions, inherited actions will // NOTE: this will only remove local actions, inherited actions will
@ -1365,14 +1377,16 @@ module.MetaActions = {
// NOTE: this will remove only the first occurance of a mixin. // NOTE: this will remove only the first occurance of a mixin.
mixout: function(from){ mixout: function(from){
var o = this.getMixin(from, true) var o = this.getMixin(from, true)
var target = null
// pop the mixin off the chain... // pop the mixin off the chain...
if(o != null){ if(o != null){
target = o.__proto__
o.__proto__ = o.__proto__.__proto__ o.__proto__ = o.__proto__.__proto__
this.resetHandlerCache() this.resetHandlerCache()
} }
return this return target
}, },
// Remove a set of local mixed in actions from object... // Remove a set of local mixed in actions from object...

View File

@ -1,6 +1,6 @@
{ {
"name": "ig-actions", "name": "ig-actions",
"version": "3.2.4", "version": "3.2.5",
"description": "", "description": "",
"main": "actions.js", "main": "actions.js",
"scripts": { "scripts": {