@live-change/framework
Advanced tools
Comparing version 0.2.9 to 0.2.10
@@ -197,2 +197,3 @@ const Model = require("./Model.js") | ||
this.emittedEvents = new Map() | ||
this.commited = false | ||
} | ||
@@ -218,6 +219,11 @@ | ||
} | ||
let events = this.emittedEvents.get(service) | ||
if(!events) { | ||
let events | ||
if(!this.commited) { | ||
events = this.emittedEvents.get(service) | ||
if(!events) { | ||
events = [] | ||
this.emittedEvents.set(service, events) | ||
} | ||
} else { | ||
events = [] | ||
this.emittedEvents.set(service, events) | ||
} | ||
@@ -231,2 +237,6 @@ if(Array.isArray(event)) { | ||
} | ||
if(this.commited) { | ||
this.service.dao.request(['database', 'putLog'], this.service.databaseName, | ||
this.service.name+'_events', { type: 'bucket', events, ...this.flags }) | ||
} | ||
} | ||
@@ -236,2 +246,3 @@ | ||
let promises = [] | ||
this.commited = true | ||
for(const [service, events] of this.emittedEvents.keys()) { | ||
@@ -250,2 +261,3 @@ promises.push(this.service.dao.request(['database', 'putLog'], this.service.databaseName, | ||
this.emittedEvents = [] | ||
this.commited = false | ||
} | ||
@@ -258,12 +270,23 @@ | ||
} | ||
let events | ||
if(!this.commited) { | ||
events = this.emittedEvents | ||
} else { | ||
events = [] | ||
} | ||
if(Array.isArray(event)) { | ||
for(let ev of event) if(!ev.service) ev.service = service | ||
this.emittedEvents.push(...event) | ||
events.push(...event) | ||
} else { | ||
if(!event.service) event.service = service | ||
this.emittedEvents.push(event) | ||
events.push(event) | ||
} | ||
if(this.commited) { | ||
this.service.dao.request(['database', 'putLog'], this.service.databaseName, | ||
'events', { type: 'bucket', events, ...this.flags }) | ||
} | ||
} | ||
async commit() { | ||
this.commited = true | ||
return this.service.dao.request(['database', 'putLog'], this.service.databaseName, | ||
@@ -270,0 +293,0 @@ 'events', { type: 'bucket', events: this.emittedEvents, ...this.flags }) |
{ | ||
"name": "@live-change/framework", | ||
"version": "0.2.9", | ||
"version": "0.2.10", | ||
"description": "Live Change Framework - ultimate solution for real time mobile/web apps", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
103872
2889