mirror of
https://github.com/flynx/features.js.git
synced 2025-10-29 18:30:11 +00:00
revising .handlers...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
32f3f77565
commit
fbcf99b6cd
35
features.js
35
features.js
@ -144,26 +144,36 @@ object.Constructor('Feature', {
|
|||||||
: res)
|
: res)
|
||||||
: res },
|
: res },
|
||||||
|
|
||||||
// XXX this could install the handlers in two locations:
|
// XXX HANDLERS this could install the handlers in two locations:
|
||||||
|
// - the actions object...
|
||||||
// - mixin if available...
|
// - mixin if available...
|
||||||
// - base object (currently implemented)
|
// - base object (currently implemented)
|
||||||
// should the first be done?
|
// ...the handlers should theoreticly be stored neither in the
|
||||||
// ...the andlers should theoreticly be stored neither in the
|
|
||||||
// instance nor in the mixin but rather in the action-set itself
|
// instance nor in the mixin but rather in the action-set itself
|
||||||
// on feature creation... (???)
|
// on feature creation... (???)
|
||||||
|
// ...feels like user handlers and feature handlers should be
|
||||||
|
// isolated...
|
||||||
|
// XXX setting handlers on the .__proto__ breaks...
|
||||||
setup: function(actions){
|
setup: function(actions){
|
||||||
var that = this
|
var that = this
|
||||||
|
|
||||||
// mixin actions...
|
// mixin actions...
|
||||||
|
// NOTE: this will only mixin functions and actions...
|
||||||
if(this.actions != null){
|
if(this.actions != null){
|
||||||
this.tag ?
|
this.tag ?
|
||||||
actions.mixin(this.actions, {source_tag: this.tag})
|
actions.mixin(this.actions, {source_tag: this.tag})
|
||||||
: actions.mixin(this.actions) }
|
: actions.mixin(this.actions)
|
||||||
|
// XXX HANDLERS here we will also need to copy this.actions.__action_handlers into the mixin...
|
||||||
|
//this.actions.__action_handlers
|
||||||
|
// && actions.__proto__.__action_handlers = this.actions.__action_handlers
|
||||||
|
}
|
||||||
|
|
||||||
// install handlers...
|
// install handlers...
|
||||||
if(this.handlers != null){
|
if(this.handlers != null){
|
||||||
this.handlers.forEach(function(h){
|
this.handlers.forEach(function([a, h]){
|
||||||
actions.on(h[0], that.tag, h[1]) }) }
|
// XXX HANDLERS this breaks into recursion...
|
||||||
|
//actions.__proto__.on(a, that.tag, h) }) }
|
||||||
|
actions.on(a, that.tag, h) }) }
|
||||||
|
|
||||||
// merge config...
|
// merge config...
|
||||||
// NOTE: this will merge the actual config in .config.__proto__
|
// NOTE: this will merge the actual config in .config.__proto__
|
||||||
@ -205,6 +215,7 @@ object.Constructor('Feature', {
|
|||||||
this.actions != null
|
this.actions != null
|
||||||
&& actions.mixout(this.tag || this.actions)
|
&& actions.mixout(this.tag || this.actions)
|
||||||
|
|
||||||
|
// XXX HANDLERS do we need this if .handlers if local to action...
|
||||||
this.handlers != null
|
this.handlers != null
|
||||||
&& actions.off('*', this.tag)
|
&& actions.off('*', this.tag)
|
||||||
|
|
||||||
@ -259,7 +270,6 @@ object.Constructor('Feature', {
|
|||||||
if(tag == null){
|
if(tag == null){
|
||||||
throw new Error('need a tag to make a feature out of an action') }
|
throw new Error('need a tag to make a feature out of an action') }
|
||||||
obj = {
|
obj = {
|
||||||
|
|
||||||
tag: tag,
|
tag: tag,
|
||||||
actions: obj,
|
actions: obj,
|
||||||
}
|
}
|
||||||
@ -273,6 +283,17 @@ object.Constructor('Feature', {
|
|||||||
suggested: obj,
|
suggested: obj,
|
||||||
} }
|
} }
|
||||||
|
|
||||||
|
/*/ XXX HANDLERS setup .handlers...
|
||||||
|
if(obj.handlers && obj.actions){
|
||||||
|
// NOTE: obj.actions does not have to be an action so w cheat \
|
||||||
|
// a bit here, then copy the mindings...
|
||||||
|
var tmp = Object.create(actions.MetaActions)
|
||||||
|
obj.handlers
|
||||||
|
.forEach(function([a, h]){
|
||||||
|
tmp.on(a, obj.tag, h) })
|
||||||
|
Object.assign(obj.actions, tmp) }
|
||||||
|
//*/
|
||||||
|
|
||||||
// feature-set...
|
// feature-set...
|
||||||
if(feature_set){
|
if(feature_set){
|
||||||
feature_set[obj.tag] = obj }
|
feature_set[obj.tag] = obj }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user