Comparing version 1.1.3 to 1.1.4
@@ -5,2 +5,7 @@ # Change Log | ||
<a name="1.1.4"></a> | ||
## [1.1.4](https://github.com/zerkalica/lom_atom/compare/v1.1.3...v1.1.4) (2017-09-27) | ||
<a name="1.1.3"></a> | ||
@@ -7,0 +12,0 @@ ## [1.1.3](https://github.com/zerkalica/lom_atom/compare/v1.1.2...v1.1.3) (2017-09-20) |
@@ -178,8 +178,2 @@ // eslint-disable-line | ||
Atom.prototype.get = function get$$1(force) { | ||
if (force) { | ||
this._pullPush(undefined, true); | ||
} else { | ||
this.actualize(); | ||
} | ||
var slave = this._context.last; | ||
@@ -200,2 +194,8 @@ | ||
if (force) { | ||
this._pullPush(undefined, true); | ||
} else { | ||
this.actualize(); | ||
} | ||
return this.value; | ||
@@ -235,2 +235,6 @@ }; | ||
Atom.prototype.actualize = function actualize(proposedValue) { | ||
if (this.status === ATOM_STATUS_PULLING) { | ||
throw new Error("Cyclic atom dependency of " + String(this)); | ||
} | ||
if (this.status === ATOM_STATUS_ACTUAL) { | ||
@@ -364,11 +368,11 @@ return; | ||
BaseLogger.prototype.create = function create(host, field, key) {}; | ||
BaseLogger.prototype.create = function create(host, field, key, namespace) {}; | ||
BaseLogger.prototype.destroy = function destroy(atom) {}; | ||
BaseLogger.prototype.destroy = function destroy(atom, namespace) {}; | ||
BaseLogger.prototype.status = function status(_status, atom) {}; | ||
BaseLogger.prototype.status = function status(_status, atom, namespace) {}; | ||
BaseLogger.prototype.error = function error(atom, err) {}; | ||
BaseLogger.prototype.error = function error(atom, err, namespace) {}; | ||
BaseLogger.prototype.newValue = function newValue(atom, from, to, isActualize) {}; | ||
BaseLogger.prototype.newValue = function newValue(atom, from, to, isActualize, namespace) {}; | ||
@@ -385,12 +389,12 @@ return BaseLogger; | ||
ConsoleLogger.prototype.status = function status(_status2, atom) { | ||
console.log(_status2, atom.displayName); | ||
ConsoleLogger.prototype.status = function status(_status2, atom, namespace) { | ||
console.log(namespace, _status2, atom.displayName); | ||
}; | ||
ConsoleLogger.prototype.error = function error(atom, err) { | ||
console.log('error', atom.displayName, err); | ||
ConsoleLogger.prototype.error = function error(atom, err, namespace) { | ||
console.log(namespace, 'error', atom.displayName, err); | ||
}; | ||
ConsoleLogger.prototype.newValue = function newValue(atom, from, to, isActualize) { | ||
console.log(isActualize ? 'actualize' : 'cacheSet', atom.displayName, 'from', from, 'to', to); | ||
ConsoleLogger.prototype.newValue = function newValue(atom, from, to, isActualize, namespace) { | ||
console.log(namespace, isActualize ? 'actualize' : 'cacheSet', atom.displayName, 'from', from, 'to', to); | ||
}; | ||
@@ -410,2 +414,3 @@ | ||
this._scheduled = false; | ||
this._namespace = '$'; | ||
@@ -426,3 +431,3 @@ this.__run = function () { | ||
if (this._logger !== undefined) { | ||
return this._logger.create(host, field, key); | ||
return this._logger.create(host, field, key, this._namespace); | ||
} | ||
@@ -433,3 +438,3 @@ }; | ||
if (this._logger !== undefined) { | ||
this._logger.destroy(atom); | ||
this._logger.destroy(atom, this._namespace); | ||
} | ||
@@ -445,7 +450,7 @@ }; | ||
if (to instanceof AtomWait) { | ||
this._logger.status('waiting', atom); | ||
this._logger.status('waiting', atom, this._namespace); | ||
} else if (to instanceof Error) { | ||
this._logger.error(atom, to); | ||
this._logger.error(atom, to, this._namespace); | ||
} else { | ||
this._logger.newValue(atom, from, to, isActualize); | ||
this._logger.newValue(atom, from, to, isActualize, this._namespace); | ||
} | ||
@@ -457,3 +462,3 @@ } | ||
if (this._logger !== undefined) { | ||
this._logger.status('proposeToPull', atom); | ||
this._logger.status('proposeToPull', atom, this._namespace); | ||
} | ||
@@ -468,3 +473,3 @@ | ||
if (this._logger !== undefined) { | ||
this._logger.status('proposeToReap', atom); | ||
this._logger.status('proposeToReap', atom, this._namespace); | ||
} | ||
@@ -522,7 +527,12 @@ | ||
Context.prototype.beginTransaction = function beginTransaction() { | ||
Context.prototype.beginTransaction = function beginTransaction(namespace) { | ||
var result = this._namespace; | ||
this._namespace = namespace; | ||
this._pendCount++; | ||
return result; | ||
}; | ||
Context.prototype.endTransaction = function endTransaction() { | ||
Context.prototype.endTransaction = function endTransaction(prev) { | ||
this._namespace = prev; | ||
if (this._pendCount === 1) { | ||
@@ -777,82 +787,92 @@ this._run(); | ||
function createActionMethod(t, hk, context) { | ||
var name = (t.displayName || t.constructor.displayName || t.constructor.name) + "." + hk; | ||
function action() { | ||
var result = void 0; | ||
context.beginTransaction(); | ||
var oldNamespace = context.beginTransaction(name); | ||
switch (arguments.length) { | ||
case 0: | ||
result = t[hk](); | ||
break; | ||
try { | ||
switch (arguments.length) { | ||
case 0: | ||
result = t[hk](); | ||
break; | ||
case 1: | ||
result = t[hk](arguments[0]); | ||
break; | ||
case 1: | ||
result = t[hk](arguments[0]); | ||
break; | ||
case 2: | ||
result = t[hk](arguments[0], arguments[1]); | ||
break; | ||
case 2: | ||
result = t[hk](arguments[0], arguments[1]); | ||
break; | ||
case 3: | ||
result = t[hk](arguments[0], arguments[1], arguments[2]); | ||
break; | ||
case 3: | ||
result = t[hk](arguments[0], arguments[1], arguments[2]); | ||
break; | ||
case 4: | ||
result = t[hk](arguments[0], arguments[1], arguments[2], arguments[3]); | ||
break; | ||
case 4: | ||
result = t[hk](arguments[0], arguments[1], arguments[2], arguments[3]); | ||
break; | ||
case 5: | ||
result = t[hk](arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); | ||
break; | ||
case 5: | ||
result = t[hk](arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); | ||
break; | ||
default: | ||
result = t[hk].apply(t, arguments); | ||
default: | ||
result = t[hk].apply(t, arguments); | ||
} | ||
} finally { | ||
context.endTransaction(oldNamespace); | ||
} | ||
context.endTransaction(); | ||
return result; | ||
} | ||
setFunctionName(action, hk); | ||
setFunctionName(action, name); | ||
return action; | ||
} | ||
function createActionFn(fn, name, context) { | ||
function createActionFn(fn, rawName, context) { | ||
var name = rawName || fn.displayName || fn.name; | ||
function action() { | ||
var result = void 0; | ||
context.beginTransaction(); | ||
var oldNamespace = context.beginTransaction(name); | ||
switch (arguments.length) { | ||
case 0: | ||
result = fn(); | ||
break; | ||
try { | ||
switch (arguments.length) { | ||
case 0: | ||
result = fn(); | ||
break; | ||
case 1: | ||
result = fn(arguments[0]); | ||
break; | ||
case 1: | ||
result = fn(arguments[0]); | ||
break; | ||
case 2: | ||
result = fn(arguments[0], arguments[1]); | ||
break; | ||
case 2: | ||
result = fn(arguments[0], arguments[1]); | ||
break; | ||
case 3: | ||
result = fn(arguments[0], arguments[1], arguments[2]); | ||
break; | ||
case 3: | ||
result = fn(arguments[0], arguments[1], arguments[2]); | ||
break; | ||
case 4: | ||
result = fn(arguments[0], arguments[1], arguments[2], arguments[3]); | ||
break; | ||
case 4: | ||
result = fn(arguments[0], arguments[1], arguments[2], arguments[3]); | ||
break; | ||
case 5: | ||
result = fn(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); | ||
break; | ||
case 5: | ||
result = fn(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); | ||
break; | ||
default: | ||
result = fn.apply(null, arguments); | ||
default: | ||
result = fn.apply(null, arguments); | ||
} | ||
} finally { | ||
context.endTransaction(oldNamespace); | ||
} | ||
context.endTransaction(); | ||
return result; | ||
} | ||
setFunctionName(action, name || fn.displayName || fn.name); | ||
setFunctionName(action, name); | ||
return action; | ||
@@ -859,0 +879,0 @@ } |
@@ -182,8 +182,2 @@ 'use strict'; | ||
Atom.prototype.get = function get$$1(force) { | ||
if (force) { | ||
this._pullPush(undefined, true); | ||
} else { | ||
this.actualize(); | ||
} | ||
var slave = this._context.last; | ||
@@ -204,2 +198,8 @@ | ||
if (force) { | ||
this._pullPush(undefined, true); | ||
} else { | ||
this.actualize(); | ||
} | ||
return this.value; | ||
@@ -239,2 +239,6 @@ }; | ||
Atom.prototype.actualize = function actualize(proposedValue) { | ||
if (this.status === ATOM_STATUS_PULLING) { | ||
throw new Error("Cyclic atom dependency of " + String(this)); | ||
} | ||
if (this.status === ATOM_STATUS_ACTUAL) { | ||
@@ -368,11 +372,11 @@ return; | ||
BaseLogger.prototype.create = function create(host, field, key) {}; | ||
BaseLogger.prototype.create = function create(host, field, key, namespace) {}; | ||
BaseLogger.prototype.destroy = function destroy(atom) {}; | ||
BaseLogger.prototype.destroy = function destroy(atom, namespace) {}; | ||
BaseLogger.prototype.status = function status(_status, atom) {}; | ||
BaseLogger.prototype.status = function status(_status, atom, namespace) {}; | ||
BaseLogger.prototype.error = function error(atom, err) {}; | ||
BaseLogger.prototype.error = function error(atom, err, namespace) {}; | ||
BaseLogger.prototype.newValue = function newValue(atom, from, to, isActualize) {}; | ||
BaseLogger.prototype.newValue = function newValue(atom, from, to, isActualize, namespace) {}; | ||
@@ -389,12 +393,12 @@ return BaseLogger; | ||
ConsoleLogger.prototype.status = function status(_status2, atom) { | ||
console.log(_status2, atom.displayName); | ||
ConsoleLogger.prototype.status = function status(_status2, atom, namespace) { | ||
console.log(namespace, _status2, atom.displayName); | ||
}; | ||
ConsoleLogger.prototype.error = function error(atom, err) { | ||
console.log('error', atom.displayName, err); | ||
ConsoleLogger.prototype.error = function error(atom, err, namespace) { | ||
console.log(namespace, 'error', atom.displayName, err); | ||
}; | ||
ConsoleLogger.prototype.newValue = function newValue(atom, from, to, isActualize) { | ||
console.log(isActualize ? 'actualize' : 'cacheSet', atom.displayName, 'from', from, 'to', to); | ||
ConsoleLogger.prototype.newValue = function newValue(atom, from, to, isActualize, namespace) { | ||
console.log(namespace, isActualize ? 'actualize' : 'cacheSet', atom.displayName, 'from', from, 'to', to); | ||
}; | ||
@@ -414,2 +418,3 @@ | ||
this._scheduled = false; | ||
this._namespace = '$'; | ||
@@ -430,3 +435,3 @@ this.__run = function () { | ||
if (this._logger !== undefined) { | ||
return this._logger.create(host, field, key); | ||
return this._logger.create(host, field, key, this._namespace); | ||
} | ||
@@ -437,3 +442,3 @@ }; | ||
if (this._logger !== undefined) { | ||
this._logger.destroy(atom); | ||
this._logger.destroy(atom, this._namespace); | ||
} | ||
@@ -449,7 +454,7 @@ }; | ||
if (to instanceof AtomWait) { | ||
this._logger.status('waiting', atom); | ||
this._logger.status('waiting', atom, this._namespace); | ||
} else if (to instanceof Error) { | ||
this._logger.error(atom, to); | ||
this._logger.error(atom, to, this._namespace); | ||
} else { | ||
this._logger.newValue(atom, from, to, isActualize); | ||
this._logger.newValue(atom, from, to, isActualize, this._namespace); | ||
} | ||
@@ -461,3 +466,3 @@ } | ||
if (this._logger !== undefined) { | ||
this._logger.status('proposeToPull', atom); | ||
this._logger.status('proposeToPull', atom, this._namespace); | ||
} | ||
@@ -472,3 +477,3 @@ | ||
if (this._logger !== undefined) { | ||
this._logger.status('proposeToReap', atom); | ||
this._logger.status('proposeToReap', atom, this._namespace); | ||
} | ||
@@ -526,7 +531,12 @@ | ||
Context.prototype.beginTransaction = function beginTransaction() { | ||
Context.prototype.beginTransaction = function beginTransaction(namespace) { | ||
var result = this._namespace; | ||
this._namespace = namespace; | ||
this._pendCount++; | ||
return result; | ||
}; | ||
Context.prototype.endTransaction = function endTransaction() { | ||
Context.prototype.endTransaction = function endTransaction(prev) { | ||
this._namespace = prev; | ||
if (this._pendCount === 1) { | ||
@@ -781,82 +791,92 @@ this._run(); | ||
function createActionMethod(t, hk, context) { | ||
var name = (t.displayName || t.constructor.displayName || t.constructor.name) + "." + hk; | ||
function action() { | ||
var result = void 0; | ||
context.beginTransaction(); | ||
var oldNamespace = context.beginTransaction(name); | ||
switch (arguments.length) { | ||
case 0: | ||
result = t[hk](); | ||
break; | ||
try { | ||
switch (arguments.length) { | ||
case 0: | ||
result = t[hk](); | ||
break; | ||
case 1: | ||
result = t[hk](arguments[0]); | ||
break; | ||
case 1: | ||
result = t[hk](arguments[0]); | ||
break; | ||
case 2: | ||
result = t[hk](arguments[0], arguments[1]); | ||
break; | ||
case 2: | ||
result = t[hk](arguments[0], arguments[1]); | ||
break; | ||
case 3: | ||
result = t[hk](arguments[0], arguments[1], arguments[2]); | ||
break; | ||
case 3: | ||
result = t[hk](arguments[0], arguments[1], arguments[2]); | ||
break; | ||
case 4: | ||
result = t[hk](arguments[0], arguments[1], arguments[2], arguments[3]); | ||
break; | ||
case 4: | ||
result = t[hk](arguments[0], arguments[1], arguments[2], arguments[3]); | ||
break; | ||
case 5: | ||
result = t[hk](arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); | ||
break; | ||
case 5: | ||
result = t[hk](arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); | ||
break; | ||
default: | ||
result = t[hk].apply(t, arguments); | ||
default: | ||
result = t[hk].apply(t, arguments); | ||
} | ||
} finally { | ||
context.endTransaction(oldNamespace); | ||
} | ||
context.endTransaction(); | ||
return result; | ||
} | ||
setFunctionName(action, hk); | ||
setFunctionName(action, name); | ||
return action; | ||
} | ||
function createActionFn(fn, name, context) { | ||
function createActionFn(fn, rawName, context) { | ||
var name = rawName || fn.displayName || fn.name; | ||
function action() { | ||
var result = void 0; | ||
context.beginTransaction(); | ||
var oldNamespace = context.beginTransaction(name); | ||
switch (arguments.length) { | ||
case 0: | ||
result = fn(); | ||
break; | ||
try { | ||
switch (arguments.length) { | ||
case 0: | ||
result = fn(); | ||
break; | ||
case 1: | ||
result = fn(arguments[0]); | ||
break; | ||
case 1: | ||
result = fn(arguments[0]); | ||
break; | ||
case 2: | ||
result = fn(arguments[0], arguments[1]); | ||
break; | ||
case 2: | ||
result = fn(arguments[0], arguments[1]); | ||
break; | ||
case 3: | ||
result = fn(arguments[0], arguments[1], arguments[2]); | ||
break; | ||
case 3: | ||
result = fn(arguments[0], arguments[1], arguments[2]); | ||
break; | ||
case 4: | ||
result = fn(arguments[0], arguments[1], arguments[2], arguments[3]); | ||
break; | ||
case 4: | ||
result = fn(arguments[0], arguments[1], arguments[2], arguments[3]); | ||
break; | ||
case 5: | ||
result = fn(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); | ||
break; | ||
case 5: | ||
result = fn(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); | ||
break; | ||
default: | ||
result = fn.apply(null, arguments); | ||
default: | ||
result = fn.apply(null, arguments); | ||
} | ||
} finally { | ||
context.endTransaction(oldNamespace); | ||
} | ||
context.endTransaction(); | ||
return result; | ||
} | ||
setFunctionName(action, name || fn.displayName || fn.name); | ||
setFunctionName(action, name); | ||
return action; | ||
@@ -863,0 +883,0 @@ } |
@@ -184,8 +184,2 @@ (function (global, factory) { | ||
Atom.prototype.get = function get$$1(force) { | ||
if (force) { | ||
this._pullPush(undefined, true); | ||
} else { | ||
this.actualize(); | ||
} | ||
var slave = this._context.last; | ||
@@ -206,2 +200,8 @@ | ||
if (force) { | ||
this._pullPush(undefined, true); | ||
} else { | ||
this.actualize(); | ||
} | ||
return this.value; | ||
@@ -241,2 +241,6 @@ }; | ||
Atom.prototype.actualize = function actualize(proposedValue) { | ||
if (this.status === ATOM_STATUS_PULLING) { | ||
throw new Error("Cyclic atom dependency of " + String(this)); | ||
} | ||
if (this.status === ATOM_STATUS_ACTUAL) { | ||
@@ -370,11 +374,11 @@ return; | ||
BaseLogger.prototype.create = function create(host, field, key) {}; | ||
BaseLogger.prototype.create = function create(host, field, key, namespace) {}; | ||
BaseLogger.prototype.destroy = function destroy(atom) {}; | ||
BaseLogger.prototype.destroy = function destroy(atom, namespace) {}; | ||
BaseLogger.prototype.status = function status(_status, atom) {}; | ||
BaseLogger.prototype.status = function status(_status, atom, namespace) {}; | ||
BaseLogger.prototype.error = function error(atom, err) {}; | ||
BaseLogger.prototype.error = function error(atom, err, namespace) {}; | ||
BaseLogger.prototype.newValue = function newValue(atom, from, to, isActualize) {}; | ||
BaseLogger.prototype.newValue = function newValue(atom, from, to, isActualize, namespace) {}; | ||
@@ -391,12 +395,12 @@ return BaseLogger; | ||
ConsoleLogger.prototype.status = function status(_status2, atom) { | ||
console.log(_status2, atom.displayName); | ||
ConsoleLogger.prototype.status = function status(_status2, atom, namespace) { | ||
console.log(namespace, _status2, atom.displayName); | ||
}; | ||
ConsoleLogger.prototype.error = function error(atom, err) { | ||
console.log('error', atom.displayName, err); | ||
ConsoleLogger.prototype.error = function error(atom, err, namespace) { | ||
console.log(namespace, 'error', atom.displayName, err); | ||
}; | ||
ConsoleLogger.prototype.newValue = function newValue(atom, from, to, isActualize) { | ||
console.log(isActualize ? 'actualize' : 'cacheSet', atom.displayName, 'from', from, 'to', to); | ||
ConsoleLogger.prototype.newValue = function newValue(atom, from, to, isActualize, namespace) { | ||
console.log(namespace, isActualize ? 'actualize' : 'cacheSet', atom.displayName, 'from', from, 'to', to); | ||
}; | ||
@@ -416,2 +420,3 @@ | ||
this._scheduled = false; | ||
this._namespace = '$'; | ||
@@ -432,3 +437,3 @@ this.__run = function () { | ||
if (this._logger !== undefined) { | ||
return this._logger.create(host, field, key); | ||
return this._logger.create(host, field, key, this._namespace); | ||
} | ||
@@ -439,3 +444,3 @@ }; | ||
if (this._logger !== undefined) { | ||
this._logger.destroy(atom); | ||
this._logger.destroy(atom, this._namespace); | ||
} | ||
@@ -451,7 +456,7 @@ }; | ||
if (to instanceof AtomWait) { | ||
this._logger.status('waiting', atom); | ||
this._logger.status('waiting', atom, this._namespace); | ||
} else if (to instanceof Error) { | ||
this._logger.error(atom, to); | ||
this._logger.error(atom, to, this._namespace); | ||
} else { | ||
this._logger.newValue(atom, from, to, isActualize); | ||
this._logger.newValue(atom, from, to, isActualize, this._namespace); | ||
} | ||
@@ -463,3 +468,3 @@ } | ||
if (this._logger !== undefined) { | ||
this._logger.status('proposeToPull', atom); | ||
this._logger.status('proposeToPull', atom, this._namespace); | ||
} | ||
@@ -474,3 +479,3 @@ | ||
if (this._logger !== undefined) { | ||
this._logger.status('proposeToReap', atom); | ||
this._logger.status('proposeToReap', atom, this._namespace); | ||
} | ||
@@ -528,7 +533,12 @@ | ||
Context.prototype.beginTransaction = function beginTransaction() { | ||
Context.prototype.beginTransaction = function beginTransaction(namespace) { | ||
var result = this._namespace; | ||
this._namespace = namespace; | ||
this._pendCount++; | ||
return result; | ||
}; | ||
Context.prototype.endTransaction = function endTransaction() { | ||
Context.prototype.endTransaction = function endTransaction(prev) { | ||
this._namespace = prev; | ||
if (this._pendCount === 1) { | ||
@@ -783,82 +793,92 @@ this._run(); | ||
function createActionMethod(t, hk, context) { | ||
var name = (t.displayName || t.constructor.displayName || t.constructor.name) + "." + hk; | ||
function action() { | ||
var result = void 0; | ||
context.beginTransaction(); | ||
var oldNamespace = context.beginTransaction(name); | ||
switch (arguments.length) { | ||
case 0: | ||
result = t[hk](); | ||
break; | ||
try { | ||
switch (arguments.length) { | ||
case 0: | ||
result = t[hk](); | ||
break; | ||
case 1: | ||
result = t[hk](arguments[0]); | ||
break; | ||
case 1: | ||
result = t[hk](arguments[0]); | ||
break; | ||
case 2: | ||
result = t[hk](arguments[0], arguments[1]); | ||
break; | ||
case 2: | ||
result = t[hk](arguments[0], arguments[1]); | ||
break; | ||
case 3: | ||
result = t[hk](arguments[0], arguments[1], arguments[2]); | ||
break; | ||
case 3: | ||
result = t[hk](arguments[0], arguments[1], arguments[2]); | ||
break; | ||
case 4: | ||
result = t[hk](arguments[0], arguments[1], arguments[2], arguments[3]); | ||
break; | ||
case 4: | ||
result = t[hk](arguments[0], arguments[1], arguments[2], arguments[3]); | ||
break; | ||
case 5: | ||
result = t[hk](arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); | ||
break; | ||
case 5: | ||
result = t[hk](arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); | ||
break; | ||
default: | ||
result = t[hk].apply(t, arguments); | ||
default: | ||
result = t[hk].apply(t, arguments); | ||
} | ||
} finally { | ||
context.endTransaction(oldNamespace); | ||
} | ||
context.endTransaction(); | ||
return result; | ||
} | ||
setFunctionName(action, hk); | ||
setFunctionName(action, name); | ||
return action; | ||
} | ||
function createActionFn(fn, name, context) { | ||
function createActionFn(fn, rawName, context) { | ||
var name = rawName || fn.displayName || fn.name; | ||
function action() { | ||
var result = void 0; | ||
context.beginTransaction(); | ||
var oldNamespace = context.beginTransaction(name); | ||
switch (arguments.length) { | ||
case 0: | ||
result = fn(); | ||
break; | ||
try { | ||
switch (arguments.length) { | ||
case 0: | ||
result = fn(); | ||
break; | ||
case 1: | ||
result = fn(arguments[0]); | ||
break; | ||
case 1: | ||
result = fn(arguments[0]); | ||
break; | ||
case 2: | ||
result = fn(arguments[0], arguments[1]); | ||
break; | ||
case 2: | ||
result = fn(arguments[0], arguments[1]); | ||
break; | ||
case 3: | ||
result = fn(arguments[0], arguments[1], arguments[2]); | ||
break; | ||
case 3: | ||
result = fn(arguments[0], arguments[1], arguments[2]); | ||
break; | ||
case 4: | ||
result = fn(arguments[0], arguments[1], arguments[2], arguments[3]); | ||
break; | ||
case 4: | ||
result = fn(arguments[0], arguments[1], arguments[2], arguments[3]); | ||
break; | ||
case 5: | ||
result = fn(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); | ||
break; | ||
case 5: | ||
result = fn(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); | ||
break; | ||
default: | ||
result = fn.apply(null, arguments); | ||
default: | ||
result = fn.apply(null, arguments); | ||
} | ||
} finally { | ||
context.endTransaction(oldNamespace); | ||
} | ||
context.endTransaction(); | ||
return result; | ||
} | ||
setFunctionName(action, name || fn.displayName || fn.name); | ||
setFunctionName(action, name); | ||
return action; | ||
@@ -865,0 +885,0 @@ } |
{ | ||
"name": "lom_atom", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "Alternative implementation of eigenmethod mol_atom state management library", | ||
@@ -5,0 +5,0 @@ "publishConfig": { |
@@ -117,8 +117,2 @@ // @flow | ||
get(force?: boolean): V { | ||
if (force) { | ||
this._pullPush(undefined, true) | ||
} else { | ||
this.actualize() | ||
} | ||
const slave = this._context.last | ||
@@ -135,2 +129,8 @@ if (slave && (!slave.isComponent || !this.isComponent)) { | ||
if (force) { | ||
this._pullPush(undefined, true) | ||
} else { | ||
this.actualize() | ||
} | ||
return (this.value: any) | ||
@@ -168,2 +168,5 @@ } | ||
actualize(proposedValue?: V): void { | ||
if (this.status === ATOM_STATUS_PULLING) { | ||
throw new Error(`Cyclic atom dependency of ${String(this)}`) | ||
} | ||
if (this.status === ATOM_STATUS_ACTUAL) { | ||
@@ -170,0 +173,0 @@ return |
@@ -27,20 +27,20 @@ // @flow | ||
export class BaseLogger implements ILogger { | ||
create<V>(host: Object, field: string, key?: mixed): V | void {} | ||
destroy(atom: IAtom<*>): void {} | ||
status(status: ILoggerStatus, atom: IAtom<*>): void {} | ||
error<V>(atom: IAtom<V>, err: Error): void {} | ||
newValue<V>(atom: IAtom<any>, from?: V | Error, to: V, isActualize?: boolean): void {} | ||
create<V>(host: Object, field: string, key?: mixed, namespace: string): V | void {} | ||
destroy(atom: IAtom<*>, namespace: string): void {} | ||
status(status: ILoggerStatus, atom: IAtom<*>, namespace: string): void {} | ||
error<V>(atom: IAtom<V>, err: Error, namespace: string): void {} | ||
newValue<V>(atom: IAtom<any>, from?: V | Error, to: V, isActualize?: boolean, namespace: string): void {} | ||
} | ||
export class ConsoleLogger extends BaseLogger { | ||
status(status: ILoggerStatus, atom: IAtom<*>): void { | ||
console.log(status, atom.displayName) | ||
status(status: ILoggerStatus, atom: IAtom<*>, namespace: string): void { | ||
console.log(namespace, status, atom.displayName) | ||
} | ||
error<V>(atom: IAtom<V>, err: Error): void { | ||
console.log('error', atom.displayName, err) | ||
error<V>(atom: IAtom<V>, err: Error, namespace: string): void { | ||
console.log(namespace, 'error', atom.displayName, err) | ||
} | ||
newValue<V>(atom: IAtom<V>, from?: V | Error, to: V, isActualize?: boolean): void { | ||
console.log(isActualize ? 'actualize' : 'cacheSet', atom.displayName, 'from', from, 'to', to) | ||
newValue<V>(atom: IAtom<V>, from?: V | Error, to: V, isActualize?: boolean, namespace: string): void { | ||
console.log(namespace, isActualize ? 'actualize' : 'cacheSet', atom.displayName, 'from', from, 'to', to) | ||
} | ||
@@ -56,6 +56,7 @@ } | ||
_scheduled = false | ||
_namespace: string = '$' | ||
create<V>(host: Object, field: string, key?: mixed): V | void { | ||
if (this._logger !== undefined) { | ||
return this._logger.create(host, field, key) | ||
return this._logger.create(host, field, key, this._namespace) | ||
} | ||
@@ -66,3 +67,3 @@ } | ||
if (this._logger !== undefined) { | ||
this._logger.destroy(atom) | ||
this._logger.destroy(atom, this._namespace) | ||
} | ||
@@ -78,7 +79,7 @@ } | ||
if (to instanceof AtomWait) { | ||
this._logger.status('waiting', atom) | ||
this._logger.status('waiting', atom, this._namespace) | ||
} else if (to instanceof Error) { | ||
this._logger.error(atom, to) | ||
this._logger.error(atom, to, this._namespace) | ||
} else { | ||
this._logger.newValue(atom, from, to, isActualize) | ||
this._logger.newValue(atom, from, to, isActualize, this._namespace) | ||
} | ||
@@ -90,3 +91,3 @@ } | ||
if (this._logger !== undefined) { | ||
this._logger.status('proposeToPull', atom) | ||
this._logger.status('proposeToPull', atom, this._namespace) | ||
} | ||
@@ -99,3 +100,3 @@ this._updating.push(atom) | ||
if (this._logger !== undefined) { | ||
this._logger.status('proposeToReap', atom) | ||
this._logger.status('proposeToReap', atom, this._namespace) | ||
} | ||
@@ -156,7 +157,11 @@ this._reaping.add(atom) | ||
beginTransaction() { | ||
beginTransaction(namespace: string): string { | ||
const result = this._namespace | ||
this._namespace = namespace | ||
this._pendCount++ | ||
return result | ||
} | ||
endTransaction() { | ||
endTransaction(prev: string) { | ||
this._namespace = prev | ||
if (this._pendCount === 1) { | ||
@@ -163,0 +168,0 @@ this._run() |
@@ -17,3 +17,3 @@ // @flow | ||
*/ | ||
create<V>(host: Object, field: string, key?: mixed): V | void; | ||
create<V>(host: Object, field: string, key?: mixed, namespace: string): V | void; | ||
@@ -23,3 +23,3 @@ /** | ||
*/ | ||
destroy(atom: IAtom<*>): void; | ||
destroy(atom: IAtom<*>, namespace: string): void; | ||
@@ -32,3 +32,3 @@ /** | ||
*/ | ||
status(status: ILoggerStatus, atom: IAtom<*>): void; | ||
status(status: ILoggerStatus, atom: IAtom<*>, namespace: string): void; | ||
@@ -38,3 +38,3 @@ /** | ||
*/ | ||
error<V>(atom: IAtom<V>, err: Error): void; | ||
error<V>(atom: IAtom<V>, err: Error, namespace: string): void; | ||
@@ -45,3 +45,3 @@ /** | ||
*/ | ||
newValue<V>(atom: IAtom<V>, from?: V | Error, to: V, isActualize?: boolean): void; | ||
newValue<V>(atom: IAtom<V>, from?: V | Error, to: V, isActualize?: boolean, namespace: string): void; | ||
} | ||
@@ -58,4 +58,4 @@ | ||
unreap(atom: IAtomInt): void; | ||
beginTransaction(): void; | ||
endTransaction(): void; | ||
beginTransaction(namespace: string): string; | ||
endTransaction(oldNamespace: string): void; | ||
} | ||
@@ -62,0 +62,0 @@ |
@@ -301,19 +301,23 @@ // @flow | ||
function createActionMethod(t: Object, hk: string, context: IContext): (...args: any[]) => any { | ||
const name = `${t.displayName || t.constructor.displayName || t.constructor.name}.${hk}` | ||
function action() { | ||
let result: mixed | void | ||
context.beginTransaction() | ||
switch (arguments.length) { | ||
case 0: result = t[hk](); break | ||
case 1: result = t[hk](arguments[0]); break | ||
case 2: result = t[hk](arguments[0], arguments[1]); break | ||
case 3: result = t[hk](arguments[0], arguments[1], arguments[2]); break | ||
case 4: result = t[hk](arguments[0], arguments[1], arguments[2], arguments[3]); break | ||
case 5: result = t[hk](arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); break | ||
default: result = t[hk].apply(t, arguments) | ||
const oldNamespace = context.beginTransaction(name) | ||
try { | ||
switch (arguments.length) { | ||
case 0: result = t[hk](); break | ||
case 1: result = t[hk](arguments[0]); break | ||
case 2: result = t[hk](arguments[0], arguments[1]); break | ||
case 3: result = t[hk](arguments[0], arguments[1], arguments[2]); break | ||
case 4: result = t[hk](arguments[0], arguments[1], arguments[2], arguments[3]); break | ||
case 5: result = t[hk](arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); break | ||
default: result = t[hk].apply(t, arguments) | ||
} | ||
} finally { | ||
context.endTransaction(oldNamespace) | ||
} | ||
context.endTransaction() | ||
return result | ||
} | ||
setFunctionName(action, hk) | ||
setFunctionName(action, name) | ||
@@ -323,20 +327,24 @@ return action | ||
function createActionFn<F: Function>(fn: F, name?: string, context: IContext): F { | ||
function createActionFn<F: Function>(fn: F, rawName?: string, context: IContext): F { | ||
const name = rawName || fn.displayName || fn.name | ||
function action(): any { | ||
let result: mixed | void | ||
context.beginTransaction() | ||
switch (arguments.length) { | ||
case 0: result = fn(); break | ||
case 1: result = fn(arguments[0]); break | ||
case 2: result = fn(arguments[0], arguments[1]); break | ||
case 3: result = fn(arguments[0], arguments[1], arguments[2]); break | ||
case 4: result = fn(arguments[0], arguments[1], arguments[2], arguments[3]); break | ||
case 5: result = fn(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); break | ||
default: result = fn.apply(null, arguments) | ||
const oldNamespace = context.beginTransaction(name) | ||
try { | ||
switch (arguments.length) { | ||
case 0: result = fn(); break | ||
case 1: result = fn(arguments[0]); break | ||
case 2: result = fn(arguments[0], arguments[1]); break | ||
case 3: result = fn(arguments[0], arguments[1], arguments[2]); break | ||
case 4: result = fn(arguments[0], arguments[1], arguments[2], arguments[3]); break | ||
case 5: result = fn(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); break | ||
default: result = fn.apply(null, arguments) | ||
} | ||
} finally { | ||
context.endTransaction(oldNamespace) | ||
} | ||
context.endTransaction() | ||
return result | ||
} | ||
setFunctionName(action, name || fn.displayName || fn.name) | ||
setFunctionName(action, name) | ||
@@ -343,0 +351,0 @@ return (action: any) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
267521
3295