@live-change/framework
Advanced tools
Comparing version 0.3.24 to 0.3.25
@@ -133,9 +133,10 @@ const Model = require("./Model.js") | ||
const action = this.actions[actionName] | ||
if(action.queuedBy) { | ||
const keyFunction = typeof action.queuedBy == 'function' ? action.queuedBy : ( | ||
Array.isArray(action.queuedBy) ? (c) => JSON.stringify(action.queuedBy.map(k=>c.parameters[k])) : | ||
(c) => JSON.stringify(c.parameters[keyFunction]) ) | ||
if(action.definition.queuedBy) { | ||
const queuedBy = action.definition.queuedBy | ||
const keyFunction = typeof queuedBy == 'function' ? queuedBy : ( | ||
Array.isArray(queuedBy) ? (c) => JSON.stringify(queuedBy.map(k=>c[k])) : | ||
(c) => JSON.stringify(c[queuedBy]) ) | ||
this.commandQueue.addCommandHandler(actionName, async (command) => { | ||
let emittedEvents = new Map() | ||
const reportFinished = command.waitForEvents ? 'trigger_'+trig.id : undefined | ||
const reportFinished = action.definition.waitForEvents ? 'trigger_'+trig.id : undefined | ||
const flags = { commandId: command.id, reportFinished } | ||
@@ -148,3 +149,4 @@ const emit = this.app.splitEvents | ||
const event = await emit.commit() | ||
if(command.waitForEvents) this.app.waitForEvents(reportFinished, events, action.waitForEvents) | ||
if(action.definition.waitForEvents) | ||
this.app.waitForEvents(reportFinished, events, action.definition.waitForEvents) | ||
return result | ||
@@ -165,3 +167,4 @@ } | ||
const events = await emit.commit() | ||
if(command.waitForEvents) this.app.waitForEvents(reportFinished, events, action.waitForEvents) | ||
if(action.definition.waitForEvents) | ||
this.app.waitForEvents(reportFinished, events, action.definition.waitForEvents) | ||
return result | ||
@@ -182,8 +185,10 @@ }) | ||
{ id: triggerName+'=>'+this.name, trigger: triggerName, service: this.name }) | ||
if(trigger.queuedBy) { | ||
const keyFunction = typeof trigger.queuedBy == 'function' ? trigger.queuedBy : ( | ||
Array.isArray(trigger.queuedBy) ? (c) => JSON.stringify(trigger.queuedBy.map(k=>c.parameters[k])) : | ||
(c) => JSON.stringify(c.parameters[trigger.queuedBy]) ) | ||
if(trigger.definition.queuedBy) { | ||
const queuedBy = trigger.definition.queuedBy | ||
const keyFunction = typeof queuedBy == 'function' ? queuedBy : ( | ||
Array.isArray(queuedBy) ? (c) => JSON.stringify(queuedBy.map(k=>c[k])) : | ||
(c) => JSON.stringify(c[queuedBy]) ) | ||
this.triggerQueue.addCommandHandler(triggerName, async (trig) => { | ||
const reportFinished = trigger.waitForEvents ? 'trigger_'+trig.id : undefined | ||
console.log("QUEUED TRIGGER STARTED", trig) | ||
const reportFinished = trigger.definition.waitForEvents ? 'trigger_'+trig.id : undefined | ||
const flags = { triggerId: trig.id, reportFinished } | ||
@@ -196,3 +201,3 @@ const emit = this.app.splitEvents | ||
try { | ||
console.error("TRIGGERED!!!!!!") | ||
console.log("TRIGGERED!!") | ||
result = await trigger.execute(trig, (...args) => emit.emit(...args)) | ||
@@ -204,6 +209,12 @@ } catch (e) { | ||
const events = await emit.commit() | ||
if(trigger.waitForEvents) this.app.waitForEvents(reportFinished, events, trigger.waitForEvents) | ||
if(trigger.definition.waitForEvents) | ||
this.app.waitForEvents(reportFinished, events, trigger.definition.waitForEvents) | ||
return result | ||
} | ||
routine.key = keyFunction(trigger) | ||
try { | ||
routine.key = keyFunction(trig) | ||
} catch(e) { | ||
console.error("QUEUE KEY FUNCTION ERROR", e) | ||
} | ||
console.log("TRIGGER QUEUE KEY", routine.key) | ||
return this.keyBasedTriggerQueues.queue(routine) | ||
@@ -226,3 +237,4 @@ }) | ||
const events = await emit.commit() | ||
if(trigger.waitForEvents) this.app.waitForEvents(reportFinished, events, trigger.waitForEvents) | ||
if(trigger.definition.waitForEvents) | ||
this.app.waitForEvents(reportFinished, events, trigger.definition.waitForEvents) | ||
return result | ||
@@ -229,0 +241,0 @@ }) |
{ | ||
"name": "@live-change/framework", | ||
"version": "0.3.24", | ||
"version": "0.3.25", | ||
"description": "Live Change Framework - ultimate solution for real time mobile/web apps", | ||
@@ -46,4 +46,4 @@ "main": "index.js", | ||
"@live-change/dao": "^0.2.16", | ||
"@live-change/event-sourcing": "^0.1.7" | ||
"@live-change/event-sourcing": "^0.1.8" | ||
} | ||
} |
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
131135
3602